Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

angular dotnet core sample for project tye #477

Merged
merged 3 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions samples/apps-with-core-angular/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
obj
bin
*.db
appsettings.json
*.rdb
settings.json
publish
wwwroot
.idea
API.csproj.user
sports-center - Web Deploy.pubxml
sports-center - Web Deploy.pubxml.user
db.lock
14 changes: 14 additions & 0 deletions samples/apps-with-core-angular/Movies.Shared/Movie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Movies.Shared
{
public class Movie
{
public int MovieId { get; set; }
public string MovieName { get; set; }
public string DirectorName { get; set; }
public int ReleaseYear { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace MoviesAPI.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class MoviesController : ControllerBase
{
private readonly MoviesService _moviesService;
public MoviesController(MoviesService moviesService)
=> _moviesService = moviesService;

[HttpGet]
public IActionResult GetMovies()
=> Ok(_moviesService.GetMovies());
}
}
12 changes: 12 additions & 0 deletions samples/apps-with-core-angular/MoviesAPI/MoviesAPI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<ItemGroup>
<ProjectReference Include="..\Movies.Shared\Movies.Shared.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>


</Project>
28 changes: 28 additions & 0 deletions samples/apps-with-core-angular/MoviesAPI/MoviesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using Movies.Shared;

namespace MoviesAPI
{
public class MoviesService
{
private readonly ILogger _logger;

public MoviesService(ILogger<MoviesService> logger)
=> _logger = logger;

private List<Movie> _movies = new List<Movie>()
{
new Movie { MovieId = 1, MovieName = "Die Another Day", DirectorName = "Lee Tamahori", ReleaseYear = 2002},
new Movie { MovieId = 2, MovieName = "Top Gun", DirectorName = "Tony Scott", ReleaseYear = 1986},
new Movie { MovieId = 3, MovieName = "Jurassic Park", DirectorName = "Steven Spielberg", ReleaseYear = 1993},
new Movie { MovieId = 4, MovieName = "Independence Day", DirectorName = "Roland Emmerich", ReleaseYear = 1996},
new Movie { MovieId = 5, MovieName = "Tomorrow Never Dies", DirectorName = "Roger Spottiswoode", ReleaseYear = 1997},
};

public IEnumerable<Movie> GetMovies()
{
return _movies;
}
}
}
26 changes: 26 additions & 0 deletions samples/apps-with-core-angular/MoviesAPI/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MoviesAPI
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:25851",
"sslPort": 44327
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "movies",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MoviesAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "movies",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
62 changes: 62 additions & 0 deletions samples/apps-with-core-angular/MoviesAPI/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MoviesAPI
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSingleton<MoviesService>();

services.AddCors(options =>
{
options.AddPolicy("CorsPolicy", policy =>
{
policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin();
});
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseCors("CorsPolicy");

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
3 changes: 3 additions & 0 deletions samples/apps-with-core-angular/MoviesApp/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/package-lock.json
**/.vs/
13 changes: 13 additions & 0 deletions samples/apps-with-core-angular/MoviesApp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
46 changes: 46 additions & 0 deletions samples/apps-with-core-angular/MoviesApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
10 changes: 10 additions & 0 deletions samples/apps-with-core-angular/MoviesApp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:alpine as node

WORKDIR /src
COPY . .

RUN npm install && npm run build

FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=node /src/dist /usr/share/nginx/html/movies
27 changes: 27 additions & 0 deletions samples/apps-with-core-angular/MoviesApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MoviesApp

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.1.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Loading