├── src ├── _playground │ ├── Module5 │ │ ├── Demo5-2 │ │ │ ├── _notes.md │ │ │ ├── Demo5-2.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── Model │ │ │ │ └── Products.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ │ ├── Controllers │ │ │ │ └── ProductsController.cs │ │ │ └── Startup.cs │ │ ├── example1.png │ │ ├── example2.png │ │ ├── example3.png │ │ ├── playground │ │ │ ├── playground.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Controllers │ │ │ │ ├── Product.cs │ │ │ │ └── ProductsController.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── .vscode │ │ │ │ ├── launch.json │ │ │ │ └── tasks.json │ │ │ └── Startup.cs │ │ ├── Demo5-1 │ │ │ ├── Demo5-1.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── Models │ │ │ │ └── Product.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── Controller │ │ │ │ └── ProductsController.cs │ │ │ ├── _notes.md │ │ │ ├── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ │ └── Startup.cs │ │ └── _notes.md │ ├── README.md │ ├── Module3 │ │ ├── Demo3-1 │ │ │ ├── Models │ │ │ │ └── State.cs │ │ │ ├── Repositories │ │ │ │ ├── IStatesRepository.cs │ │ │ │ └── FakeStatesRepository.cs │ │ │ ├── Demo3-1.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Controllers │ │ │ │ └── StatesController.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── .vscode │ │ │ │ ├── launch.json │ │ │ │ └── tasks.json │ │ │ └── Startup.cs │ │ └── Demo3-2 │ │ │ ├── Models │ │ │ └── State.cs │ │ │ ├── Repositories │ │ │ ├── IStatesRepository.cs │ │ │ └── FakeStatesRepository.cs │ │ │ ├── Demo3-2.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Controllers │ │ │ └── StatesController.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── .vscode │ │ │ ├── launch.json │ │ │ └── tasks.json │ │ │ └── Startup.cs │ ├── Module4 │ │ ├── Demo4-1 │ │ │ ├── Model │ │ │ │ └── Products.cs │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── Demo4-1.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── Controllers │ │ │ │ └── ProductsController.cs │ │ │ ├── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ │ └── Startup.cs │ │ └── Demo4-2 │ │ │ ├── Model │ │ │ └── Products.cs │ │ │ ├── Demo4-2.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ ├── IProductRepository.cs │ │ │ └── FakeProductRepository.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── Controllers │ │ │ └── ProductsController.cs │ │ │ ├── .vscode │ │ │ ├── tasks.json │ │ │ └── launch.json │ │ │ └── Startup.cs │ ├── Module6 │ │ ├── Demo6_1 │ │ │ ├── Demo6_1.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Models │ │ │ │ └── Products.cs │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── _notes.md │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Controllers │ │ │ │ └── ProductsController.cs │ │ │ ├── Startup.cs │ │ │ └── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ ├── Demo6_2 │ │ │ ├── Demo6_2.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── Model │ │ │ │ └── Products.cs │ │ │ ├── _notes.md │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ │ ├── Controllers │ │ │ │ └── ProductsController.cs │ │ │ └── Startup.cs │ │ ├── Demo6_3 │ │ │ ├── Demo6_3.csproj │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ │ ├── IProductRepository.cs │ │ │ │ └── FakeProductRepository.cs │ │ │ ├── Model │ │ │ │ └── Products.cs │ │ │ ├── Controllers │ │ │ │ ├── ErrorController.cs │ │ │ │ └── ProductsController.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── Startup.cs │ │ │ └── .vscode │ │ │ │ ├── tasks.json │ │ │ │ └── launch.json │ │ └── _notes.md │ ├── Module7 │ │ └── Demo7_1 │ │ │ ├── Models │ │ │ └── v1_0 │ │ │ │ └── Products.cs │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── Repositories │ │ │ ├── IProductRepository.cs │ │ │ └── FakeProductRepository.cs │ │ │ ├── Demo7_1.csproj │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Program.cs │ │ │ ├── _notes.md │ │ │ ├── Controllers │ │ │ └── ProductsController.cs │ │ │ ├── .vscode │ │ │ ├── tasks.json │ │ │ └── launch.json │ │ │ └── Startup.cs │ └── Module8 │ │ └── Demo8_1 │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Repositories │ │ ├── IProductRepository.cs │ │ └── FakeProductRepository.cs │ │ ├── Demo8_1.csproj │ │ ├── Models │ │ └── Product.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── Program.cs │ │ ├── .vscode │ │ ├── tasks.json │ │ └── launch.json │ │ ├── Startup.cs │ │ ├── Controllers │ │ ├── ProductController.cs │ │ └── WidgetController.cs │ │ └── _notes.md ├── Starter │ ├── Starter.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Repositories │ │ ├── IProductRepository.cs │ │ └── FakeProductRepository.cs │ ├── Models │ │ └── Product.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Program.cs │ ├── Controllers │ │ └── ProductController.cs │ ├── Startup.cs │ └── .vscode │ │ ├── tasks.json │ │ └── launch.json └── Module3 │ ├── Demo3-1 │ └── Controllers │ │ └── StatesController.cs │ └── Startup.cs └── .gitignore /src/_playground/Module5/Demo5-2/_notes.md: -------------------------------------------------------------------------------- 1 | # Model Validation 2 | 3 | [Required] 4 | 5 | [EmailAddress] 6 | 7 | -------------------------------------------------------------------------------- /src/_playground/README.md: -------------------------------------------------------------------------------- 1 | The files in this folder were used in development of the course. They might not be full demo solutions. -------------------------------------------------------------------------------- /src/_playground/Module5/example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1kevgriff/BuildingApisWithAspNetCore/master/src/_playground/Module5/example1.png -------------------------------------------------------------------------------- /src/_playground/Module5/example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1kevgriff/BuildingApisWithAspNetCore/master/src/_playground/Module5/example2.png -------------------------------------------------------------------------------- /src/_playground/Module5/example3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1kevgriff/BuildingApisWithAspNetCore/master/src/_playground/Module5/example3.png -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Models/State.cs: -------------------------------------------------------------------------------- 1 | 2 | public class State 3 | { 4 | public string Name { get; set; } 5 | public string Abbreviation { get; set; } 6 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Models/State.cs: -------------------------------------------------------------------------------- 1 | 2 | public class State 3 | { 4 | public string Name { get; set; } 5 | public string Abbreviation { get; set; } 6 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Repositories/IStatesRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IStatesRepository 5 | { 6 | List GetStates(); 7 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Repositories/IStatesRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IStatesRepository 5 | { 6 | List GetStates(); 7 | } -------------------------------------------------------------------------------- /src/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Model/Products.cs: -------------------------------------------------------------------------------- 1 | public class Product 2 | { 3 | public long Id { get; set; } 4 | public string Name { get; set; } 5 | public string Description { get; set; } 6 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Model/Products.cs: -------------------------------------------------------------------------------- 1 | public class Product 2 | { 3 | public long Id { get; set; } 4 | public string Name { get; set; } 5 | public string Description { get; set; } 6 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Demo6_1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Demo6_2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Demo6_3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/playground.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Starter/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product CreateProduct(Product newProduct); 8 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Models/v1_0/Products.cs: -------------------------------------------------------------------------------- 1 | public class Product 2 | { 3 | public long Id { get; set; } 4 | public string Name { get; set; } 5 | public string Description { get; set; } 6 | public decimal Price { get; set; } 7 | } -------------------------------------------------------------------------------- /src/Starter/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Demo3-1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo3_1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Demo3-2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo3_2 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Demo4-1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo4_1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Demo4-2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo4_2 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Demo5-1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo5_1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Demo5-2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Demo5_2 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module5/playground/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Models/Products.cs: -------------------------------------------------------------------------------- 1 | 2 | public class Product 3 | { 4 | public long Id { get; set; } 5 | 6 | public string Name { get; set; } 7 | 8 | public decimal Price { get; set; } 9 | 10 | public string Description { get; set; } 11 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | List GetProducts(); 7 | Product GetProduct(long id); 8 | Product CreateProduct(Product newProduct); 9 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | public class Product 4 | { 5 | public long Id { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public decimal Price { get; set; } 10 | 11 | public string Description {get;set;} 12 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Demo7_1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Starter/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | IEnumerable GetProducts(); 7 | Product GetProductById(long id); 8 | 9 | Product CreateProduct(Product newProduct); 10 | void UpdateProduct(long id, Product updatedProduct); 11 | void DeleteProduct(long id); 12 | } -------------------------------------------------------------------------------- /src/_playground/Module5/playground/Controllers/Product.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | public class Product 4 | { 5 | public long Id { get; set; } 6 | 7 | [FromHeader(Name = "X-Kevin")] 8 | public string Name { get; set; } 9 | 10 | [FromBody] 11 | public decimal Price { get; set; } 12 | 13 | [FromBody] 14 | public string Description {get;set;} 15 | } -------------------------------------------------------------------------------- /src/_playground/Module5/playground/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Diagnostics; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ApiController] 7 | public class ProductsController : ControllerBase 8 | { 9 | [HttpPost("/api/products")] 10 | public IActionResult CreateNewProduct([FromForm]Product newProduct) 11 | { 12 | return Ok(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public interface IProductRepository 5 | { 6 | IEnumerable GetProducts(); 7 | Product GetProductById(long id); 8 | 9 | Product CreateProduct(Product newProduct); 10 | void UpdateProduct(long id, Product updatedProduct); 11 | void DeleteProduct(long id); 12 | } -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Demo8_1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | $(NoWarn);1591 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Starter/Models/Product.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | public class Product 5 | { 6 | public long Id { get; set; } 7 | 8 | [Required] 9 | [MaxLength(255)] 10 | public string Name { get; set; } 11 | 12 | [Required] 13 | [MaxLength(1024)] 14 | public string Description { get; set; } 15 | 16 | [Required] 17 | [Range(0, 1000.0)] 18 | public decimal Price { get; set; } 19 | } 20 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Models/Product.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | public class Product 5 | { 6 | public long Id { get; set; } 7 | 8 | [Required] 9 | [MaxLength(255)] 10 | public string Name { get; set; } 11 | 12 | [Required] 13 | [MaxLength(1024)] 14 | public string Description { get; set; } 15 | 16 | [Required] 17 | [Range(0, 1000.0)] 18 | public decimal Price { get; set; } 19 | } 20 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Model/Products.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | public class Product 4 | { 5 | public long Id { get; set; } 6 | 7 | [Required] 8 | public string Name { get; set; } 9 | [Required] 10 | public string Description { get; set; } 11 | 12 | [Range(0.01, 10000)] 13 | public decimal Price { get; set; } 14 | 15 | [EmailAddress] // name@domain.tld 16 | public string ContactEmailAddress {get;set;} 17 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Model/Products.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | public class Product 4 | { 5 | public long Id { get; set; } 6 | 7 | [Required] 8 | public string Name { get; set; } 9 | [Required] 10 | public string Description { get; set; } 11 | 12 | [Range(0.01, 10000)] 13 | public decimal Price { get; set; } 14 | 15 | [EmailAddress] // name@domain.tld 16 | public string ContactEmailAddress {get;set;} 17 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Model/Products.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | public class Product 4 | { 5 | public long Id { get; set; } 6 | 7 | [Required] 8 | public string Name { get; set; } 9 | [Required] 10 | public string Description { get; set; } 11 | 12 | [Range(0.01, 10000)] 13 | public decimal Price { get; set; } 14 | 15 | [EmailAddress] // name@domain.tld 16 | public string ContactEmailAddress {get;set;} 17 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Repositories/FakeStatesRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public class FakeStateRepository : IStatesRepository 5 | { 6 | public List GetStates() 7 | { 8 | return new List(){ 9 | new State() { Name = "Virginia", Abbreviation = "VA"}, 10 | new State() { Name = "Texas", Abbreviation = "TX"}, 11 | new State() { Name = "Washington", Abbreviation = "WA"} 12 | }; 13 | } 14 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Repositories/FakeStatesRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | 4 | public class FakeStateRepository : IStatesRepository 5 | { 6 | public List GetStates() 7 | { 8 | return new List(){ 9 | new State() { Name = "Virginia", Abbreviation = "VA"}, 10 | new State() { Name = "Texas", Abbreviation = "TX"}, 11 | new State() { Name = "Washington", Abbreviation = "WA"} 12 | }; 13 | } 14 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Controllers/ErrorController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Diagnostics; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | [ApiController] 5 | public class ErrorController : ControllerBase 6 | { 7 | [Route("/error")] 8 | public IActionResult Error() => Problem(); 9 | 10 | [Route("/custom-error")] 11 | public IActionResult CustomError() 12 | { 13 | var context = HttpContext.Features.Get(); 14 | 15 | return Problem(title: context.Error.Message); 16 | } 17 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Controllers/StatesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("states")] 5 | public class StatesController : ControllerBase 6 | { 7 | public StatesController() 8 | { 9 | } 10 | 11 | // GET /states 12 | [HttpGet("")] 13 | public IActionResult GetStates([FromServices]IStatesRepository statesRepository) 14 | { 15 | // TODO: get states from repository 16 | var states = statesRepository.GetStates(); 17 | 18 | return Ok(states); 19 | } 20 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/_notes.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | ```csharp 4 | [HttpGet("{id}")] 5 | public Product GetProductById(long id) 6 | { 7 | var product = _productRepository.GetProduct(id); 8 | 9 | return product; 10 | } 11 | ``` 12 | 13 | ```csharp 14 | [HttpGet("{id}")] 15 | public ActionResult GetProductById(long id) 16 | { 17 | var product = _productRepository.GetProduct(id); 18 | 19 | if (product == null) return NotFound(); 20 | 21 | return product; 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Controllers/StatesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("states")] 5 | public class StatesController : ControllerBase 6 | { 7 | private readonly IStatesRepository statesRepository; 8 | 9 | public StatesController(IStatesRepository statesRepository) 10 | { 11 | this.statesRepository = statesRepository; 12 | } 13 | 14 | 15 | // GET /states 16 | [HttpGet("")] 17 | public IActionResult GetStates() 18 | { 19 | var states = statesRepository.GetStates(); 20 | 21 | return Ok(states); 22 | } 23 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/_notes.md: -------------------------------------------------------------------------------- 1 | ```csharp 2 | public void ConfigureServices(IServiceColleciton services){ 3 | services.AddControllers().AddXmlSerializerFormatters(); 4 | } 5 | ``` 6 | 7 | ```csharp 8 | [ApiController] 9 | [Route("api/products")] 10 | [FormatFilter] 11 | public class ProductsController : ControllerBase 12 | { 13 | ``` 14 | 15 | ```csharp 16 | [HttpGet("{id}.{format?}")] 17 | public IActionResult GetProductById(long id) 18 | { 19 | var product = _productRepository.GetProduct(id); 20 | if (product == null) return NotFound(); 21 | 22 | return Ok(product); 23 | } 24 | ``` -------------------------------------------------------------------------------- /src/Module3/Demo3-1/Controllers/StatesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("states")] 5 | public class StatesController : ControllerBase 6 | { 7 | private readonly IStatesRepository statesRepository; 8 | 9 | public StatesController(IStatesRepository statesRepository) 10 | { 11 | this.statesRepository = statesRepository; 12 | } 13 | 14 | // GET /states 15 | [HttpGet("")] 16 | public IActionResult GetStates([FromServices]IStatesRepository statesRepository) 17 | { 18 | // TODO: get states from repository 19 | var states = statesRepository.GetStates(); 20 | 21 | return Ok(states); 22 | } 23 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | CreateHostBuilder(args).Build().Run(); 15 | } 16 | 17 | public static IHostBuilder CreateHostBuilder(string[] args) => 18 | Host.CreateDefaultBuilder(args) 19 | .ConfigureWebHostDefaults(webBuilder => 20 | { 21 | webBuilder.UseStartup(); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /src/Starter/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:30257", 7 | "sslPort": 44345 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Starter": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Starter 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:9624", 7 | "sslPort": 44352 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo5_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:44208", 7 | "sslPort": 44336 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo3_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55066", 7 | "sslPort": 44396 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo3_2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:16478", 7 | "sslPort": 44330 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo4_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:41931", 7 | "sslPort": 44374 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo4_2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:28846", 7 | "sslPort": 44322 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo5_2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:26526", 7 | "sslPort": 44308 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo6_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56081", 7 | "sslPort": 44328 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo6_2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:14859", 7 | "sslPort": 44318 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo6_3": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:16033", 7 | "sslPort": 44366 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo7_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:42222", 7 | "sslPort": 44321 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Demo8_1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:42862", 7 | "sslPort": 44349 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "playground": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo3_1 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo3_2 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo4_1 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo4_2 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo5_1 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo5_2 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo5_2 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo5_2 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo7_1 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Demo8_1 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace playground 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public List GetProducts() 28 | { 29 | return _products; 30 | } 31 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "command": "dotnet", 9 | "type": "shell", 10 | "args": [ 11 | "build", 12 | // Ask dotnet build to generate full paths for file names. 13 | "/property:GenerateFullPaths=true", 14 | // Do not generate summary otherwise it leads to duplicate errors in Problems panel 15 | "/consoleloggerparameters:NoSummary" 16 | ], 17 | "group": "build", 18 | "presentation": { 19 | "reveal": "silent" 20 | }, 21 | "problemMatcher": "$msCompile" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | public class ProductsController : ControllerBase 5 | { 6 | private readonly IProductRepository _productRepository; 7 | 8 | public ProductsController(IProductRepository productRepository) 9 | { 10 | this._productRepository = productRepository; 11 | } 12 | 13 | // GET /products 14 | [Route("/products")] 15 | [HttpGet] 16 | public IActionResult GetProducts() 17 | { 18 | return Ok(_productRepository.GetProducts()); 19 | } 20 | 21 | // POST /products 22 | [HttpPost("/products")] 23 | public IActionResult CreateProduct(Product newProduct) 24 | { 25 | var createdProduct = _productRepository.CreateProduct(newProduct); 26 | 27 | var createdUrl = $"/products/{createdProduct.Id}"; 28 | 29 | return Created(createdUrl, createdProduct); 30 | } 31 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class FakeProductRepository : IProductRepository 6 | { 7 | private static List _products = new List(); 8 | 9 | static FakeProductRepository() 10 | { 11 | _products.Add(new Product() 12 | { 13 | Id = 0, 14 | Name = "Log", 15 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 16 | }); 17 | } 18 | 19 | public Product CreateProduct(Product newProduct) 20 | { 21 | newProduct.Id = _products.Max(p => p.Id) + 1; 22 | _products.Add(newProduct); 23 | 24 | return newProduct; 25 | } 26 | 27 | public Product GetProduct(long id) 28 | { 29 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 30 | } 31 | 32 | public List GetProducts() 33 | { 34 | return _products; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Diagnostics; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | [ApiController] 9 | [Route("/api/products")] 10 | public class ProductsController : ControllerBase 11 | { 12 | private readonly IProductRepository _productRepository; 13 | 14 | public ProductsController(IProductRepository productRepository) 15 | { 16 | this._productRepository = productRepository; 17 | } 18 | 19 | [HttpGet("")] 20 | public List GetProducts() 21 | { 22 | var products = _productRepository.GetProducts(); 23 | 24 | return products; // 200 OK 25 | } 26 | 27 | [HttpGet("{id}")] 28 | public ActionResult GetProductById(long id) 29 | { 30 | var product = _productRepository.GetProduct(id); 31 | 32 | if (product == null) return NotFound(); 33 | 34 | return product; 35 | } 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | public class FakeProductRepository : IProductRepository 7 | { 8 | private static List _products = new List(); 9 | 10 | static FakeProductRepository() 11 | { 12 | _products.Add(new Product() 13 | { 14 | Id = 0, 15 | Name = "Log", 16 | Description = "It's log, it's log. It's big, it's heavy, it's wood." 17 | }); 18 | } 19 | 20 | public Product CreateProduct(Product newProduct) 21 | { 22 | newProduct.Id = _products.Max(p => p.Id) + 1; 23 | _products.Add(newProduct); 24 | 25 | return newProduct; 26 | } 27 | 28 | public Product GetProduct(long id) 29 | { 30 | throw new NullReferenceException("An element was null."); 31 | 32 | return _products.FirstOrDefault(p => p.Id.Equals(id)); 33 | } 34 | 35 | public List GetProducts() 36 | { 37 | return _products; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Starter/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | [ApiController] 5 | [Route("api/products")] 6 | public class ProductController : ControllerBase 7 | { 8 | private readonly IProductRepository _productRepository; 9 | 10 | public ProductController(IProductRepository productRepository) 11 | { 12 | this._productRepository = productRepository; 13 | } 14 | 15 | [HttpGet("")] 16 | public IActionResult GetProducts() 17 | { 18 | var products = _productRepository.GetProducts(); 19 | 20 | return Ok(products); 21 | } 22 | 23 | [HttpGet("{id}")] 24 | public IActionResult GetProductById(long id) 25 | { 26 | var product = _productRepository.GetProductById(id); 27 | 28 | if (product == null) return NotFound(); 29 | 30 | return Ok(product); 31 | } 32 | 33 | [HttpPost("")] 34 | public IActionResult CreateNewProduct(Product newProduct) 35 | { 36 | if (!ModelState.IsValid) return BadRequest(ModelState); 37 | 38 | var p = _productRepository.CreateProduct(newProduct); 39 | 40 | return CreatedAtAction(nameof(GetProductById), new { id = p.Id }, p); 41 | } 42 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/_notes.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | ## Startup.cs 4 | 5 | ## Url 6 | 7 | ```csharp 8 | services.AddApiVersioning(setup => { 9 | setup.DefaultApiVersion = new ApiVersion(1, 0); 10 | // setup.ApiVersionReader = new QueryStringApiVersionReader("version", "ver", "v"); 11 | // setup.ApiVersionReader = new HeaderApiVersionReader("x-version"); 12 | setup.ApiVersionReader = new UrlSegmentApiVersionReader(); 13 | }); 14 | ``` 15 | 16 | ## Query String 17 | 18 | ```csharp 19 | services.AddApiVersioning(setup => { 20 | setup.DefaultApiVersion = new ApiVersion(1, 0); 21 | setup.ApiVersionReader = new QueryStringApiVersionReader("version", "ver", "v"); 22 | // setup.ApiVersionReader = new HeaderApiVersionReader("x-version"); 23 | // setup.ApiVersionReader = new UrlSegmentApiVersionReader(); 24 | }); 25 | ``` 26 | 27 | ## Headers 28 | 29 | ```csharp 30 | services.AddApiVersioning(setup => { 31 | setup.DefaultApiVersion = new ApiVersion(1, 0); 32 | // setup.ApiVersionReader = new QueryStringApiVersionReader("version", "ver", "v"); 33 | setup.ApiVersionReader = new HeaderApiVersionReader("x-version"); 34 | // setup.ApiVersionReader = new UrlSegmentApiVersionReader(); 35 | }); 36 | ``` 37 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Controller/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("api/products")] 5 | public class ProductsController : ControllerBase 6 | { 7 | private readonly IProductRepository _productRepository; 8 | 9 | public ProductsController(IProductRepository productRepository) 10 | { 11 | this._productRepository = productRepository; 12 | } 13 | 14 | [HttpGet("")] 15 | public IActionResult GetProducts([FromHeader(Name= "X-HeaderTest")] string headerTest) 16 | { 17 | var products = _productRepository.GetProducts(); 18 | 19 | return Ok(products); 20 | } 21 | 22 | [HttpGet("{id}")] 23 | public IActionResult GetProductById(long id) 24 | { 25 | var product = _productRepository.GetProduct(id); 26 | if (product == null) return NotFound(); 27 | 28 | return Ok(product); 29 | } 30 | 31 | // POST /api/products 32 | [HttpPost("")] 33 | public IActionResult CreateNewProduct(Product newProduct) 34 | { 35 | // create product... 36 | var createdProduct = _productRepository.CreateProduct(newProduct); 37 | 38 | return CreatedAtAction(nameof(GetProductById), new { id = createdProduct.Id }, createdProduct); 39 | } 40 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo3-1.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "stopAtEntry": false, 16 | "serverReadyAction": { 17 | "action": "openExternally", 18 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 19 | }, 20 | "env": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | }, 23 | "sourceFileMap": { 24 | "/Views": "${workspaceFolder}/Views" 25 | } 26 | }, 27 | { 28 | "name": ".NET Core Attach", 29 | "type": "coreclr", 30 | "request": "attach", 31 | "processId": "${command:pickProcess}" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo3-2.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "stopAtEntry": false, 16 | "serverReadyAction": { 17 | "action": "openExternally", 18 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 19 | }, 20 | "env": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | }, 23 | "sourceFileMap": { 24 | "/Views": "${workspaceFolder}/Views" 25 | } 26 | }, 27 | { 28 | "name": ".NET Core Attach", 29 | "type": "coreclr", 30 | "request": "attach", 31 | "processId": "${command:pickProcess}" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [Route("products")] 4 | public class ProductsController : ControllerBase 5 | { 6 | private readonly IProductRepository _productRepository; 7 | 8 | public ProductsController(IProductRepository productRepository) 9 | { 10 | this._productRepository = productRepository; 11 | } 12 | 13 | // GET /products 14 | [Route("")] 15 | [HttpGet] 16 | public IActionResult GetProducts() 17 | { 18 | return Ok(_productRepository.GetProducts()); 19 | } 20 | 21 | // GET /products/1 22 | [HttpGet("{id:long:min(0):max(100)}")] 23 | public IActionResult GetProductById(long id) 24 | { 25 | var product = _productRepository.GetProduct(id); 26 | 27 | // product == null 28 | if (product == null) return NotFound(); // 404 NOT FOUND 29 | 30 | return Ok(product); // 200 OK 31 | } 32 | 33 | // POST /products 34 | [HttpPost("")] 35 | public IActionResult CreateProduct(Product newProduct) 36 | { 37 | var createdProduct = _productRepository.CreateProduct(newProduct); 38 | 39 | var createdUrl = $"/products/{createdProduct.Id}"; 40 | 41 | return Created(createdUrl, createdProduct); 42 | } 43 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo5-2.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "stopAtEntry": false, 16 | "serverReadyAction": { 17 | "action": "openExternally", 18 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 19 | }, 20 | "env": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | }, 23 | "sourceFileMap": { 24 | "/Views": "${workspaceFolder}/Views" 25 | } 26 | }, 27 | { 28 | "name": ".NET Core Attach", 29 | "type": "coreclr", 30 | "request": "attach", 31 | "processId": "${command:pickProcess}" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /src/_playground/Module5/playground/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/playground.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "stopAtEntry": false, 16 | "serverReadyAction": { 17 | "action": "openExternally", 18 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 19 | }, 20 | "env": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | }, 23 | "sourceFileMap": { 24 | "/Views": "${workspaceFolder}/Views" 25 | } 26 | }, 27 | { 28 | "name": ".NET Core Attach", 29 | "type": "coreclr", 30 | "request": "attach", 31 | "processId": "${command:pickProcess}" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | public class Startup 12 | { 13 | // This method gets called by the runtime. Use this method to add services to the container. 14 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 15 | public void ConfigureServices(IServiceCollection services) 16 | { 17 | services.AddControllers(); 18 | 19 | services.AddTransient(); 20 | } 21 | 22 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 23 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 24 | { 25 | if (env.IsDevelopment()) 26 | { 27 | app.UseDeveloperExceptionPage(); 28 | } 29 | 30 | app.UseRouting(); 31 | 32 | app.UseEndpoints(endpoints => 33 | { 34 | endpoints.MapControllers(); 35 | }); 36 | } 37 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/_notes.md: -------------------------------------------------------------------------------- 1 | # Model Binding 2 | 3 | ```csharp 4 | [HttpPost("")] 5 | public IActionResult CreateNewProduct([FromBody] Product newProduct) 6 | { 7 | // create product... 8 | var createdProduct = _productRepository.CreateProduct(newProduct); 9 | 10 | return CreatedAtAction(nameof(GetProductById), new {id = createdProduct.Id}, createdProduct); 11 | } 12 | ``` 13 | 14 | ## Add XML 15 | 16 | ```csharp 17 | services.AddControllers().AddXmlSerializerFormatters(); 18 | ``` 19 | 20 | ```csharp 21 | [HttpPost("")] 22 | public IActionResult CreateNewProduct([FromForm] Product newProduct) 23 | { 24 | // create product... 25 | var createdProduct = _productRepository.CreateProduct(newProduct); 26 | 27 | return CreatedAtAction(nameof(GetProductById), new {id = createdProduct.Id}, createdProduct); 28 | } 29 | ``` 30 | 31 | ```csharp 32 | public IActionResult GetProducts([FromQuery]int page = 1, [FromQuery]int pageSize = 50) 33 | { 34 | var products = _productRepository.GetProducts(); 35 | 36 | return Ok(products); 37 | } 38 | ``` 39 | 40 | [FromHeader] 41 | ```csharp 42 | public IActionResult GetProducts([FromHeader(Name = "X-HeaderTest")] string headerTest) 43 | { 44 | var products = _productRepository.GetProducts(); 45 | 46 | return Ok(products); 47 | } 48 | 49 | ``` 50 | -------------------------------------------------------------------------------- /src/Starter/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Starter 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | } 21 | 22 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 23 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 24 | { 25 | if (env.IsDevelopment()) 26 | { 27 | app.UseDeveloperExceptionPage(); 28 | } 29 | 30 | app.UseRouting(); 31 | 32 | app.UseEndpoints(endpoints => 33 | { 34 | endpoints.MapControllers(); 35 | }); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace playground 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | } 21 | 22 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 23 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 24 | { 25 | if (env.IsDevelopment()) 26 | { 27 | app.UseDeveloperExceptionPage(); 28 | } 29 | 30 | app.UseRouting(); 31 | 32 | app.UseEndpoints(endpoints => 33 | { 34 | endpoints.MapControllers(); 35 | }); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo5_2 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | app.UseExceptionHandler("/error"); 28 | 29 | app.UseRouting(); 30 | 31 | app.UseEndpoints(endpoints => 32 | { 33 | endpoints.MapControllers(); 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("api/products")] 5 | public class ProductsController : ControllerBase 6 | { 7 | private readonly IProductRepository _productRepository; 8 | 9 | public ProductsController(IProductRepository productRepository) 10 | { 11 | this._productRepository = productRepository; 12 | } 13 | 14 | [HttpGet("")] 15 | public IActionResult GetProducts() 16 | { 17 | var products = _productRepository.GetProducts(); 18 | 19 | return Ok(products); 20 | } 21 | 22 | [HttpGet("{id}")] 23 | public IActionResult GetProductById(long id) 24 | { 25 | var product = _productRepository.GetProduct(id); 26 | if (product == null) return NotFound(); 27 | 28 | return Ok(product); 29 | } 30 | 31 | // POST /api/products 32 | [HttpPost("")] 33 | public IActionResult CreateNewProduct([FromBody]Product newProduct) 34 | { 35 | if (!ModelState.IsValid) return BadRequest(ModelState); 36 | 37 | // create product... 38 | var createdProduct = _productRepository.CreateProduct(newProduct); 39 | 40 | return CreatedAtAction(nameof(GetProductById), 41 | new { id = createdProduct.Id }, 42 | createdProduct); 43 | } 44 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | // [ApiController] 4 | [Route("api/products")] 5 | public class ProductsController : ControllerBase 6 | { 7 | private readonly IProductRepository _productRepository; 8 | 9 | public ProductsController(IProductRepository productRepository) 10 | { 11 | this._productRepository = productRepository; 12 | } 13 | 14 | [HttpGet("")] 15 | public IActionResult GetProducts() 16 | { 17 | var products = _productRepository.GetProducts(); 18 | 19 | return Ok(products); 20 | } 21 | 22 | [HttpGet("{id}")] 23 | public IActionResult GetProductById(long id) 24 | { 25 | var product = _productRepository.GetProduct(id); 26 | if (product == null) return NotFound(); 27 | 28 | return Ok(product); 29 | } 30 | 31 | // POST /api/products 32 | [HttpPost("")] 33 | public IActionResult CreateNewProduct([FromBody]Product newProduct) 34 | { 35 | if (!ModelState.IsValid) return BadRequest(ModelState); 36 | 37 | // create product... 38 | var createdProduct = _productRepository.CreateProduct(newProduct); 39 | 40 | return CreatedAtAction(nameof(GetProductById), 41 | new { id = createdProduct.Id }, 42 | createdProduct); 43 | } 44 | } -------------------------------------------------------------------------------- /src/Starter/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Starter.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Starter.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Starter.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Diagnostics; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | 9 | // api/1.1/products 10 | [ApiController] 11 | [Route("/api/products")] 12 | [Route("/api/{version:apiVersion}/products")] 13 | public class ProductsController : ControllerBase 14 | { 15 | private readonly IProductRepository _productRepository; 16 | 17 | public ProductsController(IProductRepository productRepository) 18 | { 19 | this._productRepository = productRepository; 20 | } 21 | 22 | [HttpGet("")] 23 | [ApiVersion("1.0")] 24 | public List GetProducts() 25 | { 26 | var products = _productRepository.GetProducts(); 27 | 28 | return products; // 200 OK 29 | } 30 | 31 | [HttpGet("")] 32 | [ApiVersion("1.1")] 33 | public List GetProducts([FromQuery] string filter) 34 | { 35 | var products = _productRepository.GetProducts(); 36 | 37 | return products; // 200 OK 38 | } 39 | 40 | [HttpGet("{id}")] 41 | public ActionResult GetProductById(long id) 42 | { 43 | var product = _productRepository.GetProduct(id); 44 | 45 | if (product == null) return NotFound(); 46 | 47 | return product; 48 | } 49 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo3-1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo3-1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo3-1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo3-2.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo3-2.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo3-2.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo4-1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo4-1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo4-1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo4-2.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo4-2.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo4-2.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo5-1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo5-1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo5-1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo6_1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo6_1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo6_1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo6_2.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo6_2.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo6_2.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo6_3.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo6_3.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo6_3.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo7_1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo7_1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo7_1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Demo8_1.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Demo8_1.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Demo8_1.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/Module3/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Module3 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module5/playground/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/playground.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/playground.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/playground.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/Starter/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | public class FakeProductRepository : IProductRepository 7 | { 8 | private static List Products; 9 | static FakeProductRepository() 10 | { 11 | Products = new List(); 12 | Products.Add(new Product() { Id = 0, Name = "Log", Description = "It's big. It's heavy. It's wood.", Price = 9.99m }); 13 | Products.Add(new Product() { Id = 1, Name = "Twig", Description = "It's small. It's light. It's wood.", Price = 5.99m }); 14 | } 15 | 16 | public Product CreateProduct(Product newProduct) 17 | { 18 | newProduct.Id = Products.Max(x => x.Id) + 1; 19 | Products.Add(newProduct); 20 | 21 | return newProduct; 22 | } 23 | 24 | public void DeleteProduct(long id) 25 | { 26 | Products.RemoveAt(Products.FindIndex(p => p.Id == id)); 27 | } 28 | 29 | public Product GetProductById(long id) 30 | { 31 | return Products.FirstOrDefault(p => p.Id == id); 32 | } 33 | 34 | public IEnumerable GetProducts() 35 | { 36 | return Products; 37 | } 38 | 39 | public void UpdateProduct(long id, Product updatedProduct) 40 | { 41 | var index = Products.FindIndex(p => p.Id == id); 42 | 43 | updatedProduct.Id = id; 44 | Products[index] = updatedProduct; 45 | } 46 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-2/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo3_2 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-2/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo5_2 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo4_1 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo4_2 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Repositories/FakeProductRepository.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | public class FakeProductRepository : IProductRepository 7 | { 8 | private static List Products; 9 | static FakeProductRepository() 10 | { 11 | Products = new List(); 12 | Products.Add(new Product() { Id = 0, Name = "Log", Description = "It's big. It's heavy. It's wood.", Price = 9.99m }); 13 | Products.Add(new Product() { Id = 1, Name = "Twig", Description = "It's small. It's light. It's wood.", Price = 5.99m }); 14 | } 15 | 16 | public Product CreateProduct(Product newProduct) 17 | { 18 | newProduct.Id = Products.Max(x => x.Id) + 1; 19 | Products.Add(newProduct); 20 | 21 | return newProduct; 22 | } 23 | 24 | public void DeleteProduct(long id) 25 | { 26 | Products.RemoveAt(Products.FindIndex(p => p.Id == id)); 27 | } 28 | 29 | public Product GetProductById(long id) 30 | { 31 | return Products.FirstOrDefault(p => p.Id == id); 32 | } 33 | 34 | public IEnumerable GetProducts() 35 | { 36 | return Products; 37 | } 38 | 39 | public void UpdateProduct(long id, Product updatedProduct) 40 | { 41 | var index = Products.FindIndex(p => p.Id == id); 42 | 43 | updatedProduct.Id = id; 44 | Products[index] = updatedProduct; 45 | } 46 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | [ApiController] 4 | [Route("api/products")] 5 | [FormatFilter] 6 | public class ProductsController : ControllerBase 7 | { 8 | private readonly IProductRepository _productRepository; 9 | 10 | public ProductsController(IProductRepository productRepository) 11 | { 12 | this._productRepository = productRepository; 13 | } 14 | 15 | [HttpGet("")] 16 | public IActionResult GetProducts() 17 | { 18 | var products = _productRepository.GetProducts(); 19 | 20 | return Ok(products); 21 | } 22 | 23 | // api/products/1.json 24 | // api/products/1.xml 25 | [HttpGet("{id}.{format?}")] 26 | public IActionResult GetProductById(long id) 27 | { 28 | var product = _productRepository.GetProduct(id); 29 | if (product == null) return NotFound(); 30 | 31 | return Ok(product); 32 | } 33 | 34 | // POST /api/products 35 | [HttpPost("")] 36 | public IActionResult CreateNewProduct([FromBody]Product newProduct) 37 | { 38 | if (!ModelState.IsValid) return BadRequest(ModelState); 39 | 40 | // create product... 41 | var createdProduct = _productRepository.CreateProduct(newProduct); 42 | 43 | return CreatedAtAction(nameof(GetProductById), 44 | new { id = createdProduct.Id }, 45 | createdProduct); 46 | } 47 | } -------------------------------------------------------------------------------- /src/_playground/Module3/Demo3-1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo3_1 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers(); 20 | 21 | services.AddTransient(); // create new instance every time 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo5_2 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers().AddXmlSerializerFormatters(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Demo5_1 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllers().AddXmlSerializerFormatters(); 20 | 21 | services.AddTransient(); 22 | } 23 | 24 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 25 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 26 | { 27 | if (env.IsDevelopment()) 28 | { 29 | app.UseDeveloperExceptionPage(); 30 | } 31 | 32 | app.UseRouting(); 33 | 34 | app.UseEndpoints(endpoints => 35 | { 36 | endpoints.MapControllers(); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Starter/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Starter.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo4-1.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module4/Demo4-2/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo4-2.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module5/Demo5-1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo5-1.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo6_1.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_2/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo6_2.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module6/Demo6_3/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo6_3.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo7_1.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Demo8_1.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/_playground/Module7/Demo7_1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | using Microsoft.AspNetCore.Mvc.Versioning; 11 | using Microsoft.AspNetCore.Mvc; 12 | 13 | namespace Demo7_1 14 | { 15 | public class Startup 16 | { 17 | // This method gets called by the runtime. Use this method to add services to the container. 18 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 19 | public void ConfigureServices(IServiceCollection services) 20 | { 21 | services.AddControllers(); 22 | services.AddApiVersioning(options => 23 | { 24 | options.DefaultApiVersion = new ApiVersion(1, 1); 25 | options.ReportApiVersions = true; 26 | options.AssumeDefaultVersionWhenUnspecified = true; 27 | 28 | options.ApiVersionReader = ApiVersionReader.Combine( 29 | new QueryStringApiVersionReader("version", "ver", "v"), 30 | new HeaderApiVersionReader("x-version") 31 | ); 32 | }); 33 | 34 | services.AddTransient(); 35 | } 36 | 37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 39 | { 40 | if (env.IsDevelopment()) 41 | { 42 | app.UseDeveloperExceptionPage(); 43 | } 44 | 45 | app.UseRouting(); 46 | 47 | app.UseEndpoints(endpoints => 48 | { 49 | endpoints.MapControllers(); 50 | }); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Hosting; 12 | using Microsoft.OpenApi.Models; 13 | 14 | namespace Demo8_1 15 | { 16 | public class Startup 17 | { 18 | // This method gets called by the runtime. Use this method to add services to the container. 19 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 20 | public void ConfigureServices(IServiceCollection services) 21 | { 22 | services.AddControllers().AddXmlSerializerFormatters(); 23 | 24 | services.AddSwaggerGen(c => 25 | { 26 | // Set the comments path for the Swagger JSON and UI. 27 | var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; 28 | var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); 29 | c.IncludeXmlComments(xmlPath); 30 | }); 31 | 32 | services.AddTransient(); 33 | } 34 | 35 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 36 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 37 | { 38 | if (env.IsDevelopment()) 39 | { 40 | app.UseDeveloperExceptionPage(); 41 | } 42 | 43 | app.UseRouting(); 44 | 45 | app.UseSwagger(); 46 | app.UseSwaggerUI(c => 47 | { 48 | c.SwaggerEndpoint("/swagger/v1/swagger.json", "Product API"); 49 | }); 50 | 51 | app.UseEndpoints(endpoints => 52 | { 53 | endpoints.MapControllers(); 54 | }); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/_playground/Module5/_notes.md: -------------------------------------------------------------------------------- 1 | # Module 5 Notes 2 | 3 | ## Data Manipulation 4 | 5 | ```csharp 6 | // example3.png 7 | [HttpPost("")] 8 | public IActionResult CreateNewProduct([FromBody]Product newProduct) 9 | { 10 | // ... 11 | } 12 | ``` 13 | 14 | [HttpPost] - Create new entity 15 | [HttpPut] - Replace an entity 16 | [HttpDelete] - Delete an entity 17 | [HttpPatch] - Patch/update an entity 18 | 19 | ## What is model binding? 20 | 21 | Taking requests data and turning it into objects. 22 | 23 | ### Basic-binding 24 | 25 | ### Example: JSON to POCO 26 | 27 | ```json 28 | // example2.png 29 | { 30 | "id": -1, 31 | "name": "Wonder Thingy", 32 | "price": 9.99, 33 | "description": "It does everything you can possibly imagine." 34 | } 35 | ``` 36 | 37 | ```csharp 38 | // example1.png 39 | public class Product 40 | { 41 | public long Id { get; set; } 42 | public string Name { get; set; } 43 | public decimal Price { get; set; } 44 | public string Description {get;set;} 45 | } 46 | ``` 47 | 48 | [FromBody] 49 | 50 | ```csharp 51 | [HttpPost("/api/products")] 52 | public IActionResult CreateNewProduct([FromBody]Product newProduct) 53 | { 54 | return Ok(); 55 | } 56 | ``` 57 | 58 | [FromQuery] 59 | 60 | ```csharp 61 | [HttpGet("/api/products")] 62 | public IActionResult GetProducts([FromQuery]int page, 63 | [FromQuery]int pageSize) 64 | { 65 | return Ok(); 66 | } 67 | ``` 68 | 69 | [FromHeader] 70 | 71 | ```csharp 72 | [HttpPost("/api/products")] 73 | public IActionResult CreateNewProduct(Product newProduct, 74 | [FromHeader(Name = "X-ApplicationId")] string applicationId) 75 | { 76 | return Ok(); 77 | } 78 | ``` 79 | 80 | [FromRoute] 81 | ```csharp 82 | [HttpGet("/api/products/{productId}")] 83 | public IActionResult GetProduct([FromRoute(Name="productId")] int pId) 84 | { 85 | return Content($"Product Id = {pId}"); 86 | } 87 | ``` 88 | 89 | [FromForm] 90 | ``` 91 | TODO: example 92 | ``` 93 | 94 | ## DEMO: Examples of Binding 95 | 96 | ## Model Validation 97 | 98 | Ensure that incoming data is "good" data. 99 | 100 | `https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations` 101 | 102 | [Required] 103 | 104 | [EmailAddress] 105 | 106 | [Phone] 107 | 108 | [RegularExpression] // if you hate yourself. 109 | 110 | Model.IsValid 111 | 112 | - Custom attributes are a thing. 113 | 114 | ## DEMO: Model Validation 115 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | [ApiController] 5 | [Route("api/products")] 6 | public class ProductController : ControllerBase 7 | { 8 | private readonly IProductRepository _productRepository; 9 | 10 | public ProductController(IProductRepository productRepository) 11 | { 12 | this._productRepository = productRepository; 13 | } 14 | 15 | /// 16 | /// Returns products from the products repository. 17 | /// 18 | /// 19 | /// Sample request: 20 | /// 21 | /// GET /api/product 22 | /// 23 | /// 24 | /// An array of products. 25 | /// An array of products. 26 | [HttpGet("")] 27 | [ProducesResponseType(typeof(IEnumerable), 200)] 28 | [Produces("application/json", "application/xml")] 29 | public IActionResult GetProducts() 30 | { 31 | var products = _productRepository.GetProducts(); 32 | 33 | return Ok(products); 34 | } 35 | 36 | /// 37 | /// Returns product from the products repository by its ID. 38 | /// 39 | /// 40 | /// Sample request: 41 | /// 42 | /// GET /api/product/10 43 | /// 44 | /// 45 | /// A product 46 | /// A product 47 | /// A product with given Id could not be found. 48 | [HttpGet("{id}")] 49 | [ProducesResponseType(typeof(Product), 200)] 50 | [ProducesResponseType(404)] 51 | [Produces("application/json", "application/xml")] 52 | public IActionResult GetProductById(long id) 53 | { 54 | var product = _productRepository.GetProductById(id); 55 | 56 | if (product == null) return NotFound(); 57 | 58 | return Ok(product); 59 | } 60 | 61 | /// 62 | /// Creates a new product. 63 | /// 64 | /// 65 | /// Sample request: 66 | /// 67 | /// POST /api/product 68 | /// { 69 | /// "name": "Product Name", 70 | /// "description": "Product Description", 71 | /// "price": 199.50 72 | /// } 73 | /// 74 | /// A product 75 | /// A newly created product 76 | /// Product has invalid data. 77 | [HttpPost("")] 78 | [ProducesResponseType(typeof(Product), 201)] 79 | [ProducesResponseType(400)] 80 | [Produces("application/json", "application/xml")] 81 | public IActionResult CreateNewProduct(Product newProduct) 82 | { 83 | if (!ModelState.IsValid) return BadRequest(ModelState); 84 | 85 | var p = _productRepository.CreateProduct(newProduct); 86 | 87 | return CreatedAtAction(nameof(GetProductById), new { id = p.Id }, p); 88 | } 89 | } -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/Controllers/WidgetController.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Collections.Generic; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | [ApiController] 6 | [Route("api/widget")] 7 | public class WidgetController : ControllerBase 8 | { 9 | private readonly IProductRepository _productRepository; 10 | 11 | public WidgetController(IProductRepository productRepository) 12 | { 13 | this._productRepository = productRepository; 14 | } 15 | 16 | /// 17 | /// Returns products from the products repository. 18 | /// 19 | /// 20 | /// Sample request: 21 | /// 22 | /// GET /api/product 23 | /// 24 | /// 25 | /// An array of products. 26 | /// An array of products. 27 | [HttpGet("")] 28 | [ProducesResponseType(typeof(IEnumerable), 200)] 29 | [Produces("application/json", "application/xml")] 30 | public IActionResult GetProducts() 31 | { 32 | var products = _productRepository.GetProducts(); 33 | 34 | return Ok(products); 35 | } 36 | 37 | /// 38 | /// Returns product from the products repository by its ID. 39 | /// 40 | /// 41 | /// Sample request: 42 | /// 43 | /// GET /api/product/10 44 | /// 45 | /// 46 | /// A product 47 | /// A product 48 | /// A product with given Id could not be found. 49 | [HttpGet("{id}")] 50 | [ProducesResponseType(typeof(Product), 200)] 51 | [ProducesResponseType(404)] 52 | [Produces("application/json", "application/xml")] 53 | public IActionResult GetProductById(long id) 54 | { 55 | var product = _productRepository.GetProductById(id); 56 | 57 | if (product == null) return NotFound(); 58 | 59 | return Ok(product); 60 | } 61 | 62 | /// 63 | /// Creates a new product. 64 | /// 65 | /// 66 | /// Sample request: 67 | /// 68 | /// POST /api/product 69 | /// { 70 | /// "name": "Product Name", 71 | /// "description": "Product Description", 72 | /// "price": 199.50 73 | /// } 74 | /// 75 | /// A product 76 | /// A newly created product 77 | /// Product has invalid data. 78 | [HttpPost("")] 79 | [ProducesResponseType(typeof(Product), 201)] 80 | [ProducesResponseType(400)] 81 | [Produces("application/json", "application/xml")] 82 | public IActionResult CreateNewProduct(Product newProduct) 83 | { 84 | if (!ModelState.IsValid) return BadRequest(ModelState); 85 | 86 | var p = _productRepository.CreateProduct(newProduct); 87 | 88 | return CreatedAtAction(nameof(GetProductById), new { id = p.Id }, p); 89 | } 90 | } -------------------------------------------------------------------------------- /src/_playground/Module6/_notes.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | ## Introduction 4 | 5 | ## Types of Results 6 | 7 | 1. IActionResult 8 | 9 | ```csharp 10 | public IActionResult GetProducts() 11 | { 12 | var products = _productRepository.GetProducts(); 13 | return Ok(products); 14 | } 15 | ``` 16 | 17 | 2. Typed Response 18 | 19 | ```csharp 20 | public List GetProducts2(long id) 21 | { 22 | return new List(); // 200 OK 23 | } 24 | ``` 25 | 26 | 3. ActionResult 27 | 28 | ```csharp 29 | [HttpGet("{id}")] 30 | public async Task> GetProductById(long id) 31 | { 32 | var product = await _productRepository.GetById(id); 33 | if (product == null) return NotFound(); 34 | 35 | return product; 36 | } 37 | ``` 38 | 39 | ## Content Negotiation 40 | 41 | 1. Change the `Accept` header. ASP.NET Core does this for you automatically if configure service is initialized properly. 42 | 43 | ```csharp 44 | public void ConfigureServices(IServiceCollection services) 45 | { 46 | services.AddControllers().AddXmlSerializerFormatters(); 47 | } 48 | ``` 49 | 50 | 2. Format extensions 51 | 52 | ```csharp 53 | [ApiController] 54 | [Route("/api/products")] 55 | [FormatFilter] 56 | public class ProductController : ControllerBase 57 | { 58 | [HttpGet("")] 59 | public IActionResult GetProducts1() 60 | { 61 | var products = new List(){ 62 | new Product() { Id = 0, Name = "Log", Price = 1.99m, Description = "It's log."}, 63 | new Product() { Id = 1, Name = "Log #2", Price = 5.99m, Description = "It's another log."}, 64 | }; 65 | 66 | return Ok(products); 67 | } 68 | 69 | [HttpGet("{id}.{format?}")] 70 | public IActionResult GetProducts1(long id) 71 | { 72 | var products = new List(){ 73 | new Product() { Id = 0, Name = "Log", Price = 1.99m, Description = "It's log."}, 74 | new Product() { Id = 1, Name = "Log #2", Price = 5.99m, Description = "It's another log."}, 75 | }; 76 | 77 | var product = products.FirstOrDefault(p => p.Id == id); 78 | if (product == null) return NotFound(); 79 | 80 | return Ok(product); 81 | } 82 | } 83 | ``` 84 | 85 | ## Error Handling 86 | 87 | * 500 Internal Server Error is a catch all if something goes wrong 88 | * Try to use acceptable HTTP status codes for errors, but only when the client can change their behavior. 89 | 90 | 400s 91 | 400 Bad Request 92 | 403 Forbidden 93 | 404 Not Found 94 | 95 | * Conversation about error handling in APIs 96 | * Generic "web apps" return HTML-based error pages, no useful 97 | * Or out-of-the-box ASP.NET Core returns status code 500, but no details 98 | * https://tools.ietf.org/html/rfc7807 99 | 100 | * .UseExceptionHandler("/error") 101 | * Generic 500, something happened. 102 | 103 | ```csharp 104 | public class HomeController : ControllerBase 105 | { 106 | [Route("/error")] 107 | public IActionResult Error() => Problem(); 108 | ``` 109 | 110 | * .UseExceptionHandle("/detailedError") 111 | * create a custom exception 112 | * if custom exception is thrown, override the title and description of Problem() 113 | 114 | ```csharp 115 | [Route("/error")] 116 | public IActionResult Error() => Problem(title: "...", detail: "..."); 117 | ``` 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/_playground/Module8/Demo8_1/_notes.md: -------------------------------------------------------------------------------- 1 | # API Documentation 2 | 3 | ## Startup 4 | 5 | ```csharp 6 | services.AddSwaggerGen(c => 7 | { 8 | c.SwaggerDoc("v1", new OpenApiInfo 9 | { 10 | Version = "v1", 11 | Title = "Product API", 12 | Description = "A simple API for products", 13 | TermsOfService = new Uri("https://consultwithgriff.com"), 14 | Contact = new OpenApiContact 15 | { 16 | Name = "Kevin Griffin", 17 | Email = "kevin@consultwithgriff.com", 18 | Url = new Uri("https://consultwithgriff.com"), 19 | } 20 | }); 21 | 22 | // Set the comments path for the Swagger JSON and UI. 23 | var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; 24 | var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); 25 | c.IncludeXmlComments(xmlPath); 26 | }); 27 | 28 | app.UseSwagger(); 29 | 30 | app.UseSwaggerUI(c => 31 | { 32 | c.SwaggerEndpoint("/swagger/v1/swagger.json", "Product API"); 33 | }); 34 | ``` 35 | 36 | ## Controller 37 | 38 | ```csharp 39 | /// 40 | /// Returns products from the products repository. 41 | /// 42 | /// 43 | /// Sample request: 44 | /// 45 | /// GET /api/product 46 | /// 47 | /// 48 | /// An array of products. 49 | /// An array of products. 50 | [HttpGet("")] 51 | [ProducesResponseType(typeof(IEnumerable), 200)] 52 | [Produces("application/json", "application/xml")] 53 | public IActionResult GetProducts() 54 | { 55 | var products = _productRepository.GetProducts(); 56 | 57 | return Ok(products); 58 | } 59 | 60 | /// 61 | /// Returns product from the products repository by its ID. 62 | /// 63 | /// 64 | /// Sample request: 65 | /// 66 | /// GET /api/product/10 67 | /// 68 | /// 69 | /// A product 70 | /// A product 71 | /// A product with given Id could not be found. 72 | [HttpGet("{id}")] 73 | [ProducesResponseType(typeof(Product), 200)] 74 | [ProducesResponseType(404)] 75 | [Produces("application/json", "application/xml")] 76 | public IActionResult GetProductById(long id) 77 | { 78 | var product = _productRepository.GetProductById(id); 79 | 80 | if (product == null) return NotFound(); 81 | 82 | return Ok(product); 83 | } 84 | 85 | /// 86 | /// Creates a new product. 87 | /// 88 | /// 89 | /// Sample request: 90 | /// 91 | /// POST /api/product 92 | /// { 93 | /// "name": "Product Name", 94 | /// "description": "Product Description", 95 | /// "price": 199.50 96 | /// } 97 | /// 98 | /// A product 99 | /// A newly created product 100 | /// Product has invalid data. 101 | [HttpPost("")] 102 | [ProducesResponseType(typeof(Product), 201)] 103 | [ProducesResponseType(400)] 104 | [Produces("application/json", "application/xml")] 105 | public IActionResult CreateNewProduct(Product newProduct) 106 | { 107 | if (!ModelState.IsValid) return BadRequest(ModelState); 108 | 109 | var p = _productRepository.CreateProduct(newProduct); 110 | 111 | return CreatedAtAction(nameof(GetProductById), new { id = p.Id }, p); 112 | } 113 | ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,visualstudio,csharp 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,visualstudio,csharp 4 | 5 | ### Csharp ### 6 | ## Ignore Visual Studio temporary files, build results, and 7 | ## files generated by popular Visual Studio add-ons. 8 | ## 9 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 10 | 11 | # User-specific files 12 | *.rsuser 13 | *.suo 14 | *.user 15 | *.userosscache 16 | *.sln.docstates 17 | 18 | # User-specific files (MonoDevelop/Xamarin Studio) 19 | *.userprefs 20 | 21 | # Mono auto generated files 22 | mono_crash.* 23 | 24 | # Build results 25 | [Dd]ebug/ 26 | [Dd]ebugPublic/ 27 | [Rr]elease/ 28 | [Rr]eleases/ 29 | x64/ 30 | x86/ 31 | [Aa][Rr][Mm]/ 32 | [Aa][Rr][Mm]64/ 33 | bld/ 34 | [Bb]in/ 35 | [Oo]bj/ 36 | [Ll]og/ 37 | [Ll]ogs/ 38 | 39 | # Visual Studio 2015/2017 cache/options directory 40 | .vs/ 41 | # Uncomment if you have tasks that create the project's static files in wwwroot 42 | #wwwroot/ 43 | 44 | # Visual Studio 2017 auto generated files 45 | Generated\ Files/ 46 | 47 | # MSTest test Results 48 | [Tt]est[Rr]esult*/ 49 | [Bb]uild[Ll]og.* 50 | 51 | # NUnit 52 | *.VisualState.xml 53 | TestResult.xml 54 | nunit-*.xml 55 | 56 | # Build Results of an ATL Project 57 | [Dd]ebugPS/ 58 | [Rr]eleasePS/ 59 | dlldata.c 60 | 61 | # Benchmark Results 62 | BenchmarkDotNet.Artifacts/ 63 | 64 | # .NET Core 65 | project.lock.json 66 | project.fragment.lock.json 67 | artifacts/ 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*[.json, .xml, .info] 147 | 148 | # Visual Studio code coverage results 149 | *.coverage 150 | *.coveragexml 151 | 152 | # NCrunch 153 | _NCrunch_* 154 | .*crunch*.local.xml 155 | nCrunchTemp_* 156 | 157 | # MightyMoose 158 | *.mm.* 159 | AutoTest.Net/ 160 | 161 | # Web workbench (sass) 162 | .sass-cache/ 163 | 164 | # Installshield output folder 165 | [Ee]xpress/ 166 | 167 | # DocProject is a documentation generator add-in 168 | DocProject/buildhelp/ 169 | DocProject/Help/*.HxT 170 | DocProject/Help/*.HxC 171 | DocProject/Help/*.hhc 172 | DocProject/Help/*.hhk 173 | DocProject/Help/*.hhp 174 | DocProject/Help/Html2 175 | DocProject/Help/html 176 | 177 | # Click-Once directory 178 | publish/ 179 | 180 | # Publish Web Output 181 | *.[Pp]ublish.xml 182 | *.azurePubxml 183 | # Note: Comment the next line if you want to checkin your web deploy settings, 184 | # but database connection strings (with potential passwords) will be unencrypted 185 | *.pubxml 186 | *.publishproj 187 | 188 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 189 | # checkin your Azure Web App publish settings, but sensitive information contained 190 | # in these scripts will be unencrypted 191 | PublishScripts/ 192 | 193 | # NuGet Packages 194 | *.nupkg 195 | # NuGet Symbol Packages 196 | *.snupkg 197 | # The packages folder can be ignored because of Package Restore 198 | **/[Pp]ackages/* 199 | # except build/, which is used as an MSBuild target. 200 | !**/[Pp]ackages/build/ 201 | # Uncomment if necessary however generally it will be regenerated when needed 202 | #!**/[Pp]ackages/repositories.config 203 | # NuGet v3's project.json files produces more ignorable files 204 | *.nuget.props 205 | *.nuget.targets 206 | 207 | # Microsoft Azure Build Output 208 | csx/ 209 | *.build.csdef 210 | 211 | # Microsoft Azure Emulator 212 | ecf/ 213 | rcf/ 214 | 215 | # Windows Store app package directories and files 216 | AppPackages/ 217 | BundleArtifacts/ 218 | Package.StoreAssociation.xml 219 | _pkginfo.txt 220 | *.appx 221 | *.appxbundle 222 | *.appxupload 223 | 224 | # Visual Studio cache files 225 | # files ending in .cache can be ignored 226 | *.[Cc]ache 227 | # but keep track of directories ending in .cache 228 | !?*.[Cc]ache/ 229 | 230 | # Others 231 | ClientBin/ 232 | ~$* 233 | *~ 234 | *.dbmdl 235 | *.dbproj.schemaview 236 | *.jfm 237 | *.pfx 238 | *.publishsettings 239 | orleans.codegen.cs 240 | 241 | # Including strong name files can present a security risk 242 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 243 | #*.snk 244 | 245 | # Since there are multiple workflows, uncomment next line to ignore bower_components 246 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 247 | #bower_components/ 248 | 249 | # RIA/Silverlight projects 250 | Generated_Code/ 251 | 252 | # Backup & report files from converting an old project file 253 | # to a newer Visual Studio version. Backup files are not needed, 254 | # because we have git ;-) 255 | _UpgradeReport_Files/ 256 | Backup*/ 257 | UpgradeLog*.XML 258 | UpgradeLog*.htm 259 | ServiceFabricBackup/ 260 | *.rptproj.bak 261 | 262 | # SQL Server files 263 | *.mdf 264 | *.ldf 265 | *.ndf 266 | 267 | # Business Intelligence projects 268 | *.rdl.data 269 | *.bim.layout 270 | *.bim_*.settings 271 | *.rptproj.rsuser 272 | *- [Bb]ackup.rdl 273 | *- [Bb]ackup ([0-9]).rdl 274 | *- [Bb]ackup ([0-9][0-9]).rdl 275 | 276 | # Microsoft Fakes 277 | FakesAssemblies/ 278 | 279 | # GhostDoc plugin setting file 280 | *.GhostDoc.xml 281 | 282 | # Node.js Tools for Visual Studio 283 | .ntvs_analysis.dat 284 | node_modules/ 285 | 286 | # Visual Studio 6 build log 287 | *.plg 288 | 289 | # Visual Studio 6 workspace options file 290 | *.opt 291 | 292 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 293 | *.vbw 294 | 295 | # Visual Studio LightSwitch build output 296 | **/*.HTMLClient/GeneratedArtifacts 297 | **/*.DesktopClient/GeneratedArtifacts 298 | **/*.DesktopClient/ModelManifest.xml 299 | **/*.Server/GeneratedArtifacts 300 | **/*.Server/ModelManifest.xml 301 | _Pvt_Extensions 302 | 303 | # Paket dependency manager 304 | .paket/paket.exe 305 | paket-files/ 306 | 307 | # FAKE - F# Make 308 | .fake/ 309 | 310 | # CodeRush personal settings 311 | .cr/personal 312 | 313 | # Python Tools for Visual Studio (PTVS) 314 | __pycache__/ 315 | *.pyc 316 | 317 | # Cake - Uncomment if you are using it 318 | # tools/** 319 | # !tools/packages.config 320 | 321 | # Tabs Studio 322 | *.tss 323 | 324 | # Telerik's JustMock configuration file 325 | *.jmconfig 326 | 327 | # BizTalk build output 328 | *.btp.cs 329 | *.btm.cs 330 | *.odx.cs 331 | *.xsd.cs 332 | 333 | # OpenCover UI analysis results 334 | OpenCover/ 335 | 336 | # Azure Stream Analytics local run output 337 | ASALocalRun/ 338 | 339 | # MSBuild Binary and Structured Log 340 | *.binlog 341 | 342 | # NVidia Nsight GPU debugger configuration file 343 | *.nvuser 344 | 345 | # MFractors (Xamarin productivity tool) working folder 346 | .mfractor/ 347 | 348 | # Local History for Visual Studio 349 | .localhistory/ 350 | 351 | # BeatPulse healthcheck temp database 352 | healthchecksdb 353 | 354 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 355 | MigrationBackup/ 356 | 357 | # Ionide (cross platform F# VS Code tools) working folder 358 | .ionide/ 359 | 360 | ### VisualStudioCode ### 361 | .vscode/* 362 | !.vscode/settings.json 363 | !.vscode/tasks.json 364 | !.vscode/launch.json 365 | !.vscode/extensions.json 366 | *.code-workspace 367 | 368 | ### VisualStudioCode Patch ### 369 | # Ignore all local history of files 370 | .history 371 | 372 | ### VisualStudio ### 373 | 374 | # User-specific files 375 | 376 | # User-specific files (MonoDevelop/Xamarin Studio) 377 | 378 | # Mono auto generated files 379 | 380 | # Build results 381 | 382 | # Visual Studio 2015/2017 cache/options directory 383 | # Uncomment if you have tasks that create the project's static files in wwwroot 384 | 385 | # Visual Studio 2017 auto generated files 386 | 387 | # MSTest test Results 388 | 389 | # NUnit 390 | 391 | # Build Results of an ATL Project 392 | 393 | # Benchmark Results 394 | 395 | # .NET Core 396 | 397 | # StyleCop 398 | 399 | # Files built by Visual Studio 400 | 401 | # Chutzpah Test files 402 | 403 | # Visual C++ cache files 404 | 405 | # Visual Studio profiler 406 | 407 | # Visual Studio Trace Files 408 | 409 | # TFS 2012 Local Workspace 410 | 411 | # Guidance Automation Toolkit 412 | 413 | # ReSharper is a .NET coding add-in 414 | 415 | # TeamCity is a build add-in 416 | 417 | # DotCover is a Code Coverage Tool 418 | 419 | # AxoCover is a Code Coverage Tool 420 | 421 | # Coverlet is a free, cross platform Code Coverage Tool 422 | 423 | # Visual Studio code coverage results 424 | 425 | # NCrunch 426 | 427 | # MightyMoose 428 | 429 | # Web workbench (sass) 430 | 431 | # Installshield output folder 432 | 433 | # DocProject is a documentation generator add-in 434 | 435 | # Click-Once directory 436 | 437 | # Publish Web Output 438 | # Note: Comment the next line if you want to checkin your web deploy settings, 439 | # but database connection strings (with potential passwords) will be unencrypted 440 | 441 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 442 | # checkin your Azure Web App publish settings, but sensitive information contained 443 | # in these scripts will be unencrypted 444 | 445 | # NuGet Packages 446 | # NuGet Symbol Packages 447 | # The packages folder can be ignored because of Package Restore 448 | # except build/, which is used as an MSBuild target. 449 | # Uncomment if necessary however generally it will be regenerated when needed 450 | # NuGet v3's project.json files produces more ignorable files 451 | 452 | # Microsoft Azure Build Output 453 | 454 | # Microsoft Azure Emulator 455 | 456 | # Windows Store app package directories and files 457 | 458 | # Visual Studio cache files 459 | # files ending in .cache can be ignored 460 | # but keep track of directories ending in .cache 461 | 462 | # Others 463 | 464 | # Including strong name files can present a security risk 465 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 466 | 467 | # Since there are multiple workflows, uncomment next line to ignore bower_components 468 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 469 | 470 | # RIA/Silverlight projects 471 | 472 | # Backup & report files from converting an old project file 473 | # to a newer Visual Studio version. Backup files are not needed, 474 | # because we have git ;-) 475 | 476 | # SQL Server files 477 | 478 | # Business Intelligence projects 479 | 480 | # Microsoft Fakes 481 | 482 | # GhostDoc plugin setting file 483 | 484 | # Node.js Tools for Visual Studio 485 | 486 | # Visual Studio 6 build log 487 | 488 | # Visual Studio 6 workspace options file 489 | 490 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 491 | 492 | # Visual Studio LightSwitch build output 493 | 494 | # Paket dependency manager 495 | 496 | # FAKE - F# Make 497 | 498 | # CodeRush personal settings 499 | 500 | # Python Tools for Visual Studio (PTVS) 501 | 502 | # Cake - Uncomment if you are using it 503 | # tools/** 504 | # !tools/packages.config 505 | 506 | # Tabs Studio 507 | 508 | # Telerik's JustMock configuration file 509 | 510 | # BizTalk build output 511 | 512 | # OpenCover UI analysis results 513 | 514 | # Azure Stream Analytics local run output 515 | 516 | # MSBuild Binary and Structured Log 517 | 518 | # NVidia Nsight GPU debugger configuration file 519 | 520 | # MFractors (Xamarin productivity tool) working folder 521 | 522 | # Local History for Visual Studio 523 | 524 | # BeatPulse healthcheck temp database 525 | 526 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 527 | 528 | # Ionide (cross platform F# VS Code tools) working folder 529 | 530 | # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,visualstudio,csharp --------------------------------------------------------------------------------