├── 978-1-4842-9347-8.jpg
├── ch04
└── FirstApi
│ ├── FirstApi
│ ├── Models
│ │ └── ShipperModel.cs
│ ├── appsettings.json
│ ├── appsettings.Development.json
│ ├── WeatherForecast.cs
│ ├── FirstApi.csproj
│ ├── Properties
│ │ └── launchSettings.json
│ └── Controllers
│ │ └── WeatherForecastController.cs
│ ├── DIRegistration
│ ├── Program.cs
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── DIRegistration.csproj
│ └── Properties
│ │ └── launchSettings.json
│ ├── Lifetimes
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── WeatherForecast.cs
│ ├── Lifetimes.csproj
│ ├── MyServiceLifetime.cs
│ ├── Program.cs
│ ├── Controllers
│ │ └── WeatherForecastController.cs
│ └── Properties
│ │ └── launchSettings.json
│ └── Routing
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── Controllers
│ ├── TestController.cs
│ └── WeatherForecastController.cs
│ ├── WeatherForecast.cs
│ ├── Routing.csproj
│ ├── Program.cs
│ └── Properties
│ └── launchSettings.json
├── ch07
├── end
│ └── ConferenceApi
│ │ ├── Conference.Domain
│ │ ├── Class1.cs
│ │ ├── Entities
│ │ │ ├── Talk.cs
│ │ │ ├── Speaker.cs
│ │ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ └── SpeakerProfile.cs
│ │ └── Models
│ │ │ └── SpeakerModel.cs
│ │ ├── Conference.Data
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ └── Conference.Service
│ │ └── Conference.Service.csproj
└── start
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── Models
│ │ └── SpeakerModel.cs
│ ├── Program.cs
│ └── ConferenceApi.csproj
│ └── ConferenceApi.sln
├── ch08
├── start
│ └── ConferenceApi
│ │ ├── Conference.Domain
│ │ ├── Class1.cs
│ │ ├── Entities
│ │ │ ├── Talk.cs
│ │ │ ├── Speaker.cs
│ │ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ └── SpeakerProfile.cs
│ │ └── Models
│ │ │ └── SpeakerModel.cs
│ │ ├── Conference.Data
│ │ ├── TalksRepository.cs
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ └── Conference.Service
│ │ └── Conference.Service.csproj
└── end
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── Models
│ │ ├── TalkModel.cs
│ │ └── SpeakerModel.cs
│ ├── appsettings.json
│ ├── Mappings
│ │ ├── TalkProfile.cs
│ │ └── SpeakerProfile.cs
│ ├── Controllers
│ │ ├── TalksController.cs
│ │ ├── ValuesController.cs
│ │ └── AwesomeController.cs
│ └── Infrastructure
│ │ └── Constraints
│ │ └── EmailRouteConstraint.cs
│ ├── Conference.Data
│ ├── Conference.Data.csproj
│ └── ITalksRepository.cs
│ ├── Conference.Service
│ └── Conference.Service.csproj
│ └── Conference.Domain
│ ├── Entities
│ ├── Talk.cs
│ ├── Speaker.cs
│ └── ConferenceContext.cs
│ ├── Extensions
│ └── ConferenceContext.cs
│ └── Conference.Domain.csproj
├── ch06
├── end
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Domain
│ │ │ ├── Talk.cs
│ │ │ ├── Speaker.cs
│ │ │ └── ConferenceContext.cs
│ │ ├── WeatherForecast.cs
│ │ ├── Models
│ │ │ └── SpeakerModel.cs
│ │ ├── ConferenceApi.csproj
│ │ ├── Program.cs
│ │ └── Controllers
│ │ │ └── WeatherForecastController.cs
│ │ └── ConferenceApi.sln
├── start
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ ├── Domain
│ │ │ ├── Talk.cs
│ │ │ ├── Speaker.cs
│ │ │ └── ConferenceContext.cs
│ │ ├── WeatherForecast.cs
│ │ ├── Models
│ │ │ └── SpeakerModel.cs
│ │ ├── ConferenceApi.csproj
│ │ ├── Program.cs
│ │ └── Controllers
│ │ │ └── WeatherForecastController.cs
│ │ └── ConferenceApi.sln
└── scaffold_project
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── Models
│ │ └── SpeakerModel.cs
│ ├── Domain
│ │ ├── Talk.cs
│ │ └── Speaker.cs
│ ├── Program.cs
│ └── ConferenceApi.csproj
│ └── ConferenceApi.sln
├── ch09
├── begin
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── Models
│ │ │ ├── TalkModel.cs
│ │ │ └── SpeakerModel.cs
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ ├── TalkProfile.cs
│ │ │ └── SpeakerProfile.cs
│ │ ├── Controllers
│ │ │ ├── TalksController.cs
│ │ │ ├── ValuesController.cs
│ │ │ └── AwesomeController.cs
│ │ └── Infrastructure
│ │ │ └── Constraints
│ │ │ └── EmailRouteConstraint.cs
│ │ ├── Conference.Data
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ ├── Conference.Service
│ │ └── Conference.Service.csproj
│ │ └── Conference.Domain
│ │ ├── Entities
│ │ ├── Talk.cs
│ │ ├── Speaker.cs
│ │ └── ConferenceContext.cs
│ │ ├── Extensions
│ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
└── end
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── Models
│ │ ├── TalkModel.cs
│ │ └── SpeakerModel.cs
│ ├── appsettings.json
│ ├── Mappings
│ │ ├── TalkProfile.cs
│ │ └── SpeakerProfile.cs
│ ├── Controllers
│ │ ├── TalksController.cs
│ │ ├── ValuesController.cs
│ │ └── AwesomeController.cs
│ └── Infrastructure
│ │ ├── Middleware
│ │ ├── Extensions
│ │ │ └── MiddlewareExtensions.cs
│ │ └── SecurityHeadersMiddleware.cs
│ │ └── Constraints
│ │ └── EmailRouteConstraint.cs
│ ├── Conference.Data
│ ├── Conference.Data.csproj
│ └── ITalksRepository.cs
│ ├── Conference.Service
│ └── Conference.Service.csproj
│ └── Conference.Domain
│ ├── Entities
│ ├── Talk.cs
│ ├── Speaker.cs
│ └── ConferenceContext.cs
│ ├── Extensions
│ └── ConferenceContext.cs
│ └── Conference.Domain.csproj
├── ch10
├── begin
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── Models
│ │ │ ├── TalkModel.cs
│ │ │ └── SpeakerModel.cs
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ ├── TalkProfile.cs
│ │ │ └── SpeakerProfile.cs
│ │ ├── Controllers
│ │ │ ├── TalksController.cs
│ │ │ ├── ValuesController.cs
│ │ │ └── AwesomeController.cs
│ │ └── Infrastructure
│ │ │ ├── Middleware
│ │ │ ├── Extensions
│ │ │ │ └── MiddlewareExtensions.cs
│ │ │ └── SecurityHeadersMiddleware.cs
│ │ │ └── Constraints
│ │ │ └── EmailRouteConstraint.cs
│ │ ├── Conference.Data
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ ├── Conference.Service
│ │ └── Conference.Service.csproj
│ │ └── Conference.Domain
│ │ ├── Entities
│ │ ├── Talk.cs
│ │ ├── Speaker.cs
│ │ └── ConferenceContext.cs
│ │ ├── Extensions
│ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
└── end
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── Models
│ │ ├── TalkModel.cs
│ │ ├── MyModel.cs
│ │ ├── SpeakerAddress.cs
│ │ ├── FilterModel.cs
│ │ ├── HeaderValues.cs
│ │ └── SpeakerModel.cs
│ ├── appsettings.json
│ ├── Mappings
│ │ ├── TalkProfile.cs
│ │ └── SpeakerProfile.cs
│ ├── Controllers
│ │ ├── TalksController.cs
│ │ ├── ValuesController.cs
│ │ └── AwesomeController.cs
│ └── Infrastructure
│ │ ├── Middleware
│ │ ├── Extensions
│ │ │ └── MiddlewareExtensions.cs
│ │ └── SecurityHeadersMiddleware.cs
│ │ ├── ValueProviders
│ │ └── CommaQueryStringValueProviderFactory.cs
│ │ ├── Constraints
│ │ └── EmailRouteConstraint.cs
│ │ └── Attributes
│ │ └── CommaQueryStringAttribute.cs
│ ├── Conference.Data
│ ├── Conference.Data.csproj
│ └── ITalksRepository.cs
│ ├── Conference.Service
│ └── Conference.Service.csproj
│ └── Conference.Domain
│ ├── Entities
│ ├── Talk.cs
│ ├── Speaker.cs
│ └── ConferenceContext.cs
│ ├── Extensions
│ └── ConferenceContext.cs
│ └── Conference.Domain.csproj
├── ch11
├── begin
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── Models
│ │ │ ├── TalkModel.cs
│ │ │ ├── MyModel.cs
│ │ │ ├── SpeakerAddress.cs
│ │ │ ├── FilterModel.cs
│ │ │ ├── HeaderValues.cs
│ │ │ └── SpeakerModel.cs
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ ├── TalkProfile.cs
│ │ │ └── SpeakerProfile.cs
│ │ ├── Controllers
│ │ │ ├── TalksController.cs
│ │ │ ├── ValuesController.cs
│ │ │ └── AwesomeController.cs
│ │ └── Infrastructure
│ │ │ ├── Middleware
│ │ │ ├── Extensions
│ │ │ │ └── MiddlewareExtensions.cs
│ │ │ └── SecurityHeadersMiddleware.cs
│ │ │ ├── ValueProviders
│ │ │ └── CommaQueryStringValueProviderFactory.cs
│ │ │ ├── Constraints
│ │ │ └── EmailRouteConstraint.cs
│ │ │ ├── Attributes
│ │ │ └── CommaQueryStringAttribute.cs
│ │ │ └── OpenAPi
│ │ │ └── ConfigureSwaggerOptions.cs
│ │ ├── Conference.Data
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ ├── Conference.Service
│ │ └── Conference.Service.csproj
│ │ └── Conference.Domain
│ │ ├── Entities
│ │ ├── Talk.cs
│ │ ├── Speaker.cs
│ │ └── ConferenceContext.cs
│ │ ├── Extensions
│ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
└── end
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── Models
│ │ ├── TalkModel.cs
│ │ ├── MyModel.cs
│ │ ├── SpeakerModelV2.cs
│ │ ├── SpeakerAddress.cs
│ │ ├── FilterModel.cs
│ │ ├── HeaderValues.cs
│ │ └── SpeakerModel.cs
│ ├── appsettings.json
│ ├── Mappings
│ │ ├── TalkProfile.cs
│ │ └── SpeakerProfile.cs
│ ├── Controllers
│ │ ├── TalksController.cs
│ │ ├── ValuesController.cs
│ │ ├── AwesomeController.cs
│ │ └── SpeakersControllerV2.cs
│ └── Infrastructure
│ │ ├── Middleware
│ │ ├── Extensions
│ │ │ └── MiddlewareExtensions.cs
│ │ └── SecurityHeadersMiddleware.cs
│ │ ├── ValueProviders
│ │ └── CommaQueryStringValueProviderFactory.cs
│ │ ├── Constraints
│ │ └── EmailRouteConstraint.cs
│ │ ├── Attributes
│ │ └── CommaQueryStringAttribute.cs
│ │ └── OpenAPi
│ │ └── ConfigureSwaggerOptions.cs
│ ├── Conference.Data
│ ├── Conference.Data.csproj
│ └── ITalksRepository.cs
│ ├── Conference.Service
│ └── Conference.Service.csproj
│ └── Conference.Domain
│ ├── Entities
│ ├── Talk.cs
│ ├── Speaker.cs
│ └── ConferenceContext.cs
│ ├── Extensions
│ └── ConferenceContext.cs
│ └── Conference.Domain.csproj
├── ch12
├── begin
│ └── ConferenceApi
│ │ ├── ConferenceApi
│ │ ├── appsettings.Development.json
│ │ ├── Models
│ │ │ ├── TalkModel.cs
│ │ │ ├── MyModel.cs
│ │ │ ├── SpeakerModelV2.cs
│ │ │ ├── SpeakerAddress.cs
│ │ │ ├── FilterModel.cs
│ │ │ ├── HeaderValues.cs
│ │ │ └── SpeakerModel.cs
│ │ ├── appsettings.json
│ │ ├── Mappings
│ │ │ ├── TalkProfile.cs
│ │ │ └── SpeakerProfile.cs
│ │ ├── Controllers
│ │ │ ├── TalksController.cs
│ │ │ ├── ValuesController.cs
│ │ │ ├── AwesomeController.cs
│ │ │ └── SpeakersControllerV2.cs
│ │ └── Infrastructure
│ │ │ ├── Middleware
│ │ │ ├── Extensions
│ │ │ │ └── MiddlewareExtensions.cs
│ │ │ └── SecurityHeadersMiddleware.cs
│ │ │ ├── ValueProviders
│ │ │ └── CommaQueryStringValueProviderFactory.cs
│ │ │ ├── Constraints
│ │ │ └── EmailRouteConstraint.cs
│ │ │ ├── Attributes
│ │ │ └── CommaQueryStringAttribute.cs
│ │ │ └── OpenAPi
│ │ │ └── ConfigureSwaggerOptions.cs
│ │ ├── Conference.Data
│ │ ├── Conference.Data.csproj
│ │ └── ITalksRepository.cs
│ │ ├── Conference.Service
│ │ └── Conference.Service.csproj
│ │ └── Conference.Domain
│ │ ├── Entities
│ │ ├── Talk.cs
│ │ ├── Speaker.cs
│ │ └── ConferenceContext.cs
│ │ ├── Extensions
│ │ └── ConferenceContext.cs
│ │ └── Conference.Domain.csproj
└── end
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── Models
│ │ ├── TalkModel.cs
│ │ ├── MyModel.cs
│ │ ├── SpeakerModelV2.cs
│ │ ├── SpeakerAddress.cs
│ │ ├── FilterModel.cs
│ │ ├── HeaderValues.cs
│ │ └── SpeakerModel.cs
│ ├── appsettings.json
│ ├── Mappings
│ │ ├── TalkProfile.cs
│ │ └── SpeakerProfile.cs
│ ├── Controllers
│ │ ├── TalksController.cs
│ │ ├── ValuesController.cs
│ │ ├── AwesomeController.cs
│ │ └── SpeakersControllerV2.cs
│ └── Infrastructure
│ │ ├── Middleware
│ │ ├── Extensions
│ │ │ └── MiddlewareExtensions.cs
│ │ └── SecurityHeadersMiddleware.cs
│ │ ├── ValueProviders
│ │ └── CommaQueryStringValueProviderFactory.cs
│ │ ├── Constraints
│ │ └── EmailRouteConstraint.cs
│ │ ├── Attributes
│ │ └── CommaQueryStringAttribute.cs
│ │ └── OpenAPi
│ │ └── ConfigureSwaggerOptions.cs
│ ├── Conference.Data
│ ├── Conference.Data.csproj
│ └── ITalksRepository.cs
│ ├── Conference.Service
│ └── Conference.Service.csproj
│ └── Conference.Domain
│ ├── Entities
│ ├── Talk.cs
│ ├── Speaker.cs
│ └── ConferenceContext.cs
│ ├── Extensions
│ └── ConferenceContext.cs
│ └── Conference.Domain.csproj
├── ch05
└── starting_point
│ └── ConferenceApi
│ ├── ConferenceApi
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── WeatherForecast.cs
│ ├── Models
│ │ └── SpeakerModel.cs
│ ├── ConferenceApi.csproj
│ ├── Program.cs
│ └── Controllers
│ │ └── WeatherForecastController.cs
│ └── ConferenceApi.sln
├── README.md
└── Contributing.md
/978-1-4842-9347-8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/Web-API-Development-for-the-Absolute-Beginner/HEAD/978-1-4842-9347-8.jpg
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/Models/ShipperModel.cs:
--------------------------------------------------------------------------------
1 | namespace FirstApi.Models
2 | {
3 | public class ShipperModel
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Domain/Class1.cs:
--------------------------------------------------------------------------------
1 | namespace Conference.Domain
2 | {
3 | public class Class1
4 | {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Domain/Class1.cs:
--------------------------------------------------------------------------------
1 | namespace Conference.Domain
2 | {
3 | public class Class1
4 | {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/ch04/FirstApi/DIRegistration/Program.cs:
--------------------------------------------------------------------------------
1 | var builder = WebApplication.CreateBuilder(args);
2 | var app = builder.Build();
3 | app.MapGet("/", () => "Hello World!");
4 | app.Run();
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch04/FirstApi/DIRegistration/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch04/FirstApi/DIRegistration/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Information"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Information",
6 | "Microsoft" : "Debug"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Domain/Talk.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Domain
2 | {
3 | public class Talk
4 | {
5 | public int Id { get; set; }
6 | public string Title { get; set; }
7 | public string Description { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Domain/Talk.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Domain
2 | {
3 | public class Talk
4 | {
5 | public int Id { get; set; }
6 | public string Title { get; set; }
7 | public string Description { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Data/TalksRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Conference.Data
8 | {
9 | public class TalksRepository
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch04/FirstApi/DIRegistration/DIRegistration.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/Controllers/TestController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace Routing.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class TestController : ControllerBase
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/TalkModel.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class TalkModel
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Title { get; set; } = null!;
8 |
9 | public string Description { get; set; } = null!;
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace FirstApi
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateTime Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace Lifetimes
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateOnly Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace Routing
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateOnly Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "ConferenceDatabase": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ConferenceDemo"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Warning"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Mappings/TalkProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class TalkProfile : Profile
8 | {
9 | public TalkProfile()
10 | {
11 | CreateMap();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateOnly Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateOnly Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi
2 | {
3 | public class WeatherForecast
4 | {
5 | public DateOnly Date { get; set; }
6 |
7 | public int TemperatureC { get; set; }
8 |
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10 |
11 | public string? Summary { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/MyModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 |
4 | namespace ConferenceApi.Models
5 | {
6 |
7 | public class MyModel
8 | {
9 | [BindNever]
10 | public int Id { get; set; }
11 |
12 | public string FirstName { get; set; }
13 | public string LastName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/MyModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 |
4 | namespace ConferenceApi.Models
5 | {
6 |
7 | public class MyModel
8 | {
9 | [BindNever]
10 | public int Id { get; set; }
11 |
12 | public string FirstName { get; set; }
13 | public string LastName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/MyModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 |
4 | namespace ConferenceApi.Models
5 | {
6 |
7 | public class MyModel
8 | {
9 | [BindNever]
10 | public int Id { get; set; }
11 |
12 | public string FirstName { get; set; }
13 | public string LastName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/MyModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 |
4 | namespace ConferenceApi.Models
5 | {
6 |
7 | public class MyModel
8 | {
9 | [BindNever]
10 | public int Id { get; set; }
11 |
12 | public string FirstName { get; set; }
13 | public string LastName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/MyModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 |
4 | namespace ConferenceApi.Models
5 | {
6 |
7 | public class MyModel
8 | {
9 | [BindNever]
10 | public int Id { get; set; }
11 |
12 | public string FirstName { get; set; }
13 | public string LastName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Data/Conference.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Service/Conference.Service.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/SpeakerModelV2.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerModelV2
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string LastName { get; set; }
8 | public string Bio { get; set; }
9 | public string Position { get; set; }
10 | public string Company { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/SpeakerModelV2.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerModelV2
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string LastName { get; set; }
8 | public string Bio { get; set; }
9 | public string Position { get; set; }
10 | public string Company { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/SpeakerModelV2.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerModelV2
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string LastName { get; set; }
8 | public string Bio { get; set; }
9 | public string Position { get; set; }
10 | public string Company { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Domain/Speaker.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Domain
2 | {
3 | public class Speaker
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string LastName { get; set; }
8 | public string Email { get; set; }
9 | public string Website { get; set; }
10 |
11 | public virtual ICollection Talks { get; set; }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/SpeakerAddress.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerAddress
4 | {
5 | public string City { get; set; }
6 | public string Country { get; set; }
7 | public string Street { get; set; }
8 | public string StreetNo { get; set; }
9 | public string ZipCode { get; set; }
10 | public string PrefferedAirport { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/SpeakerAddress.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerAddress
4 | {
5 | public string City { get; set; }
6 | public string Country { get; set; }
7 | public string Street { get; set; }
8 | public string StreetNo { get; set; }
9 | public string ZipCode { get; set; }
10 | public string PrefferedAirport { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/SpeakerAddress.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerAddress
4 | {
5 | public string City { get; set; }
6 | public string Country { get; set; }
7 | public string Street { get; set; }
8 | public string StreetNo { get; set; }
9 | public string ZipCode { get; set; }
10 | public string PrefferedAirport { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Controllers/TalksController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Data;
3 | using Conference.Domain.Entities;
4 | using ConferenceApi.Models;
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace ConferenceApi.Controllers
9 | {
10 |
11 |
12 | [ApiController]
13 | public class TalksController : ControllerBase
14 | {
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/SpeakerAddress.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerAddress
4 | {
5 | public string City { get; set; }
6 | public string Country { get; set; }
7 | public string Street { get; set; }
8 | public string StreetNo { get; set; }
9 | public string ZipCode { get; set; }
10 | public string PrefferedAirport { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/Extensions/MiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware.Extensions
2 | {
3 | public static class MiddlewareExtensions
4 | {
5 |
6 | public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder application)
7 | {
8 | return application.UseMiddleware();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/SpeakerAddress.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Models
2 | {
3 | public class SpeakerAddress
4 | {
5 | public string City { get; set; }
6 | public string Country { get; set; }
7 | public string Street { get; set; }
8 | public string StreetNo { get; set; }
9 | public string ZipCode { get; set; }
10 | public string PrefferedAirport { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Domain/Speaker.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Domain
2 | {
3 | public class Speaker
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string LastName { get; set; }
8 | public string Email { get; set; }
9 | public string Website { get; set; }
10 |
11 | public virtual ICollection Talks { get; set; }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/Domain/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ConferenceApi.Domain;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/FilterModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class FilterModel
6 | {
7 | public string PrefferedAirport { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | public SpeakerAddress Address { get; set; }
11 | public List Countries { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/HeaderValues.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class HeaderValues
6 | {
7 | [FromHeader]
8 | public string Accept { get; set; }
9 |
10 | [FromHeader(Name = "Culture")]
11 | public string Culture { get; set; }
12 |
13 | [FromHeader(Name = "Language")]
14 | public string Language { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/FilterModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class FilterModel
6 | {
7 | public string PrefferedAirport { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | public SpeakerAddress Address { get; set; }
11 | public List Countries { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/HeaderValues.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class HeaderValues
6 | {
7 | [FromHeader]
8 | public string Accept { get; set; }
9 |
10 | [FromHeader(Name = "Culture")]
11 | public string Culture { get; set; }
12 |
13 | [FromHeader(Name = "Language")]
14 | public string Language { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/FilterModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class FilterModel
6 | {
7 | public string PrefferedAirport { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | public SpeakerAddress Address { get; set; }
11 | public List Countries { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/HeaderValues.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class HeaderValues
6 | {
7 | [FromHeader]
8 | public string Accept { get; set; }
9 |
10 | [FromHeader(Name = "Culture")]
11 | public string Culture { get; set; }
12 |
13 | [FromHeader(Name = "Language")]
14 | public string Language { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/FilterModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class FilterModel
6 | {
7 | public string PrefferedAirport { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | public SpeakerAddress Address { get; set; }
11 | public List Countries { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/HeaderValues.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class HeaderValues
6 | {
7 | [FromHeader]
8 | public string Accept { get; set; }
9 |
10 | [FromHeader(Name = "Culture")]
11 | public string Culture { get; set; }
12 |
13 | [FromHeader(Name = "Language")]
14 | public string Language { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/FilterModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class FilterModel
6 | {
7 | public string PrefferedAirport { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | public SpeakerAddress Address { get; set; }
11 | public List Countries { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/HeaderValues.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class HeaderValues
6 | {
7 | [FromHeader]
8 | public string Accept { get; set; }
9 |
10 | [FromHeader(Name = "Culture")]
11 | public string Culture { get; set; }
12 |
13 | [FromHeader(Name = "Language")]
14 | public string Language { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Domain/Entities/Talk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Talk
7 | {
8 | public int Id { get; set; }
9 |
10 | public string Title { get; set; } = null!;
11 |
12 | public string Description { get; set; } = null!;
13 |
14 | public int? SpeakerId { get; set; }
15 |
16 | public virtual Speaker? Speaker { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/Routing.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/Lifetimes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | CreateMap();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | CreateMap();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Mappings/SpeakerProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Domain.Entities;
3 | using ConferenceApi.Models;
4 |
5 | namespace ConferenceApi.Mappings
6 | {
7 | public class SpeakerProfile : Profile
8 | {
9 | public SpeakerProfile()
10 | {
11 | CreateMap();
12 | CreateMap();
13 | CreateMap();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/FirstApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Conference.Service;
3 | using ConferenceApi.Models;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ConferenceApi.Controllers
8 | {
9 |
10 | public class ValuesController : ControllerBase
11 | {
12 | [HttpGet]
13 | public IActionResult GetAll()
14 | {
15 | return Ok("get all test route");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/ConferenceApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Domain/Extensions/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Domain.Extensions
9 | {
10 |
11 |
12 | public static class DbContextExtension
13 | {
14 | public static void EnsureSeeded(this ConferenceContext context)
15 | {
16 | DataSeeder.SeedData(context);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/Domain/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ConferenceApi.Domain;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 |
18 | public virtual ICollection Talks { get; } = new List();
19 | }
20 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace ConferenceApi.Models
4 | {
5 | public class SpeakerModel
6 | {
7 | public int Id { get; set; }
8 | public string FirstName { get; set; }
9 | public string LastName { get; set; }
10 | [EmailAddress]
11 | public string Email { get; set; }
12 | public string Website { get; set; }
13 | public string City { get; set; }
14 | public string Country { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Apress Source Code
2 |
3 | This repository accompanies [*Web API Development for the Absolute Beginner*](https://www.link.springer.com/book/10.1007/978-1-4842-9348-5) by Irina Dominte (Apress, 2023).
4 |
5 | [comment]: #cover
6 | 
7 |
8 | Download the files as a zip using the green button, or clone the repository to your machine using Git.
9 |
10 | ## Releases
11 |
12 | Release v1.0 corresponds to the code in the published book, without corrections or updates.
13 |
14 | ## Contributions
15 |
16 | See the file Contributing.md for more information on how you can contribute to this repository.
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Infrastructure/ValueProviders/CommaQueryStringValueProviderFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.ModelBinding;
2 | using System.Threading.Tasks;
3 |
4 | namespace Conference.Api.Infrastructure.ValueProviders
5 | {
6 |
7 | public class CommaQueryStringValueProviderFactory : IValueProviderFactory
8 | {
9 |
10 | public Task CreateValueProviderAsync(ValueProviderFactoryContext context)
11 | {
12 | context.ValueProviders.Insert(0, new CommaQueryStringValueProvider(context.ActionContext.HttpContext.Request.Query));
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/ValueProviders/CommaQueryStringValueProviderFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.ModelBinding;
2 | using System.Threading.Tasks;
3 |
4 | namespace Conference.Api.Infrastructure.ValueProviders
5 | {
6 |
7 | public class CommaQueryStringValueProviderFactory : IValueProviderFactory
8 | {
9 |
10 | public Task CreateValueProviderAsync(ValueProviderFactoryContext context)
11 | {
12 | context.ValueProviders.Insert(0, new CommaQueryStringValueProvider(context.ActionContext.HttpContext.Request.Query));
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/ValueProviders/CommaQueryStringValueProviderFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.ModelBinding;
2 | using System.Threading.Tasks;
3 |
4 | namespace Conference.Api.Infrastructure.ValueProviders
5 | {
6 |
7 | public class CommaQueryStringValueProviderFactory : IValueProviderFactory
8 | {
9 |
10 | public Task CreateValueProviderAsync(ValueProviderFactoryContext context)
11 | {
12 | context.ValueProviders.Insert(0, new CommaQueryStringValueProvider(context.ActionContext.HttpContext.Request.Query));
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/ValueProviders/CommaQueryStringValueProviderFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.ModelBinding;
2 | using System.Threading.Tasks;
3 |
4 | namespace Conference.Api.Infrastructure.ValueProviders
5 | {
6 |
7 | public class CommaQueryStringValueProviderFactory : IValueProviderFactory
8 | {
9 |
10 | public Task CreateValueProviderAsync(ValueProviderFactoryContext context)
11 | {
12 | context.ValueProviders.Insert(0, new CommaQueryStringValueProvider(context.ActionContext.HttpContext.Request.Query));
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/ValueProviders/CommaQueryStringValueProviderFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.ModelBinding;
2 | using System.Threading.Tasks;
3 |
4 | namespace Conference.Api.Infrastructure.ValueProviders
5 | {
6 |
7 | public class CommaQueryStringValueProviderFactory : IValueProviderFactory
8 | {
9 |
10 | public Task CreateValueProviderAsync(ValueProviderFactoryContext context)
11 | {
12 | context.ValueProviders.Insert(0, new CommaQueryStringValueProvider(context.ActionContext.HttpContext.Request.Query));
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Domain/Entities/Speaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Conference.Domain.Entities;
5 |
6 | public partial class Speaker
7 | {
8 | public int Id { get; set; }
9 |
10 | public string FirstName { get; set; } = null!;
11 |
12 | public string LastName { get; set; } = null!;
13 |
14 | public string Email { get; set; } = null!;
15 |
16 | public string Website { get; set; } = null!;
17 | public string City { get; set; } = null!;
18 | public string Country { get; set; } = null!;
19 |
20 | public virtual ICollection Talks { get; } = new List();
21 | }
22 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Domain/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.Extensions.Hosting;
3 | using System.Reflection.Metadata;
4 |
5 | namespace ConferenceApi.Domain
6 | {
7 | public class ConferenceContext : DbContext
8 | {
9 | public DbSet Speakers { get; set; }
10 | public DbSet Talks { get; set; }
11 |
12 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
13 | {
14 | optionsBuilder.UseSqlServer(
15 | @"Server=(localdb)\mssqllocaldb;Database=Conference;Trusted_Connection=True");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Domain/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.Extensions.Hosting;
3 | using System.Reflection.Metadata;
4 |
5 | namespace ConferenceApi.Domain
6 | {
7 | public class ConferenceContext : DbContext
8 | {
9 | public DbSet Speakers { get; set; }
10 | public DbSet Talks { get; set; }
11 |
12 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
13 | {
14 | optionsBuilder.UseSqlServer(
15 | @"Server=(localdb)\mssqllocaldb;Database=ConferenceDemo;Trusted_Connection=True");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/ConferenceApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Data/ITalksRepository.cs:
--------------------------------------------------------------------------------
1 | using Conference.Domain.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Conference.Data
9 | {
10 |
11 | public interface ITalksRepository
12 | {
13 | Talk Add(Talk newTalk);
14 | IQueryable GetAll();
15 | Talk Get(int id);
16 | Talk Update(Talk talk);
17 | bool Delete(Talk talk);
18 | bool TalkExists(int id);
19 | List GetTalksForSpeaker(int speakerId);
20 | Talk GetTalk(int speakerId, int talkId);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using ConferenceApi.Infrastructure.ModelBinders;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace ConferenceApi.Models
6 | {
7 | [ModelBinder(BinderType = typeof(SpeakerEntityBinder))]
8 | public class SpeakerModel
9 | {
10 | public int Id { get; set; }
11 | public string FirstName { get; set; }
12 | public string LastName { get; set; }
13 | [EmailAddress]
14 | public string Email { get; set; }
15 | public string Website { get; set; }
16 | public string City { get; set; }
17 | public string Country { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using ConferenceApi.Infrastructure.ModelBinders;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace ConferenceApi.Models
6 | {
7 | [ModelBinder(BinderType = typeof(SpeakerEntityBinder))]
8 | public class SpeakerModel
9 | {
10 | public int Id { get; set; }
11 | public string FirstName { get; set; }
12 | public string LastName { get; set; }
13 | [EmailAddress]
14 | public string Email { get; set; }
15 | public string Website { get; set; }
16 | public string City { get; set; }
17 | public string Country { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using ConferenceApi.Infrastructure.ModelBinders;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace ConferenceApi.Models
6 | {
7 | [ModelBinder(BinderType = typeof(SpeakerEntityBinder))]
8 | public class SpeakerModel
9 | {
10 | public int Id { get; set; }
11 | public string FirstName { get; set; }
12 | public string LastName { get; set; }
13 | [EmailAddress]
14 | public string Email { get; set; }
15 | public string Website { get; set; }
16 | public string City { get; set; }
17 | public string Country { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using ConferenceApi.Infrastructure.ModelBinders;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace ConferenceApi.Models
6 | {
7 | [ModelBinder(BinderType = typeof(SpeakerEntityBinder))]
8 | public class SpeakerModel
9 | {
10 | public int Id { get; set; }
11 | public string FirstName { get; set; }
12 | public string LastName { get; set; }
13 | [EmailAddress]
14 | public string Email { get; set; }
15 | public string Website { get; set; }
16 | public string City { get; set; }
17 | public string Country { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Models/SpeakerModel.cs:
--------------------------------------------------------------------------------
1 | using ConferenceApi.Infrastructure.ModelBinders;
2 | using Microsoft.AspNetCore.Mvc;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace ConferenceApi.Models
6 | {
7 | [ModelBinder(BinderType = typeof(SpeakerEntityBinder))]
8 | public class SpeakerModel
9 | {
10 | public int Id { get; set; }
11 | public string FirstName { get; set; }
12 | public string LastName { get; set; }
13 | [EmailAddress]
14 | public string Email { get; set; }
15 | public string Website { get; set; }
16 | public string City { get; set; }
17 | public string Country { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 |
9 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
10 | builder.Services.AddEndpointsApiExplorer();
11 | builder.Services.AddSwaggerGen();
12 | var app = builder.Build();
13 |
14 | // Configure the HTTP request pipeline.
15 | if (app.Environment.IsDevelopment())
16 | {
17 | app.UseSwagger();
18 | app.UseSwaggerUI();
19 | }
20 |
21 | app.UseHttpsRedirection();
22 |
23 | app.UseAuthorization();
24 |
25 | app.MapControllers();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 |
9 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
10 | builder.Services.AddEndpointsApiExplorer();
11 | builder.Services.AddSwaggerGen();
12 | var app = builder.Build();
13 |
14 | // Configure the HTTP request pipeline.
15 | if (app.Environment.IsDevelopment())
16 | {
17 | app.UseSwagger();
18 | app.UseSwaggerUI();
19 | }
20 |
21 | app.UseHttpsRedirection();
22 |
23 | app.UseAuthorization();
24 |
25 | app.MapControllers();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/Contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing to Apress Source Code
2 |
3 | Copyright for Apress source code belongs to the author. However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.
4 |
5 | ## How to Contribute
6 |
7 | 1. Make sure you have a GitHub account.
8 | 2. Fork the repository for the relevant book.
9 | 3. Create a new branch on which to make your change, e.g.
10 | `git checkout -b my_code_contribution`
11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
12 | 5. Submit a pull request.
13 |
14 | Thank you for your contribution!
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/MyServiceLifetime.cs:
--------------------------------------------------------------------------------
1 | namespace Lifetimes
2 | {
3 | public interface IOperation
4 | {
5 | public string LifetimeId { get; }
6 | }
7 |
8 | public interface ITransientOperation : IOperation
9 | {
10 |
11 | }
12 |
13 | public interface IScopedOperation : IOperation
14 | {
15 | }
16 |
17 | public interface ISingletonOperation : IOperation
18 | {
19 | }
20 |
21 |
22 | public class MyServiceLifetime : ITransientOperation, IScopedOperation, ISingletonOperation
23 | {
24 | public MyServiceLifetime()
25 | {
26 | LifetimeId = Guid.NewGuid().ToString()[^4..];
27 | }
28 |
29 | public string LifetimeId { get; }
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/Constraints/EmailRouteConstraint.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace ConferenceApi.Infrastructure.Constraints
4 | {
5 |
6 | public class EmailRouteConstraint : IRouteConstraint
7 | {
8 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
9 | {
10 | if (!values.TryGetValue(routeKey, out var value) || value == null)
11 | {
12 | return false;
13 | }
14 |
15 | var email = value.ToString();
16 | return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/Program.cs:
--------------------------------------------------------------------------------
1 | var builder = WebApplication.CreateBuilder(args);
2 |
3 | // Add services to the container.
4 |
5 | builder.Services.AddControllers();
6 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
7 | builder.Services.AddEndpointsApiExplorer();
8 | builder.Services.AddSwaggerGen();
9 |
10 | var app = builder.Build();
11 |
12 | // Configure the HTTP request pipeline.
13 | if (app.Environment.IsDevelopment())
14 | {
15 | app.UseSwagger();
16 | app.UseSwaggerUI();
17 | }
18 |
19 | app.UseAuthorization();
20 | app.UseRouting();
21 | app.UseEndpoints(endpoints =>
22 | {
23 | endpoints.MapControllers();
24 | });
25 |
26 | //app.MapControllers();
27 | app.MapDefaultControllerRoute();
28 |
29 | app.Run();
30 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Domain/Conference.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/Program.cs:
--------------------------------------------------------------------------------
1 | using Lifetimes;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9 | builder.Services.AddEndpointsApiExplorer();
10 | builder.Services.AddSwaggerGen();
11 | builder.Services.AddTransient();
12 | builder.Services.AddSingleton();
13 | builder.Services.AddScoped();
14 | var app = builder.Build();
15 |
16 | // Configure the HTTP request pipeline.
17 | if (app.Environment.IsDevelopment())
18 | {
19 | app.UseSwagger();
20 | app.UseSwaggerUI();
21 | }
22 |
23 | app.UseHttpsRedirection();
24 |
25 | app.UseAuthorization();
26 |
27 | app.MapControllers();
28 |
29 | app.Run();
30 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/ConferenceApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:49174",
8 | "sslPort": 0
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "launchUrl": "swagger",
17 | "applicationUrl": "http://localhost:5026",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "IIS Express": {
23 | "commandName": "IISExpress",
24 | "launchBrowser": true,
25 | "launchUrl": "swagger",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:24840",
8 | "sslPort": 44336
9 | }
10 | },
11 | "profiles": {
12 | "FirstApi": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "launchUrl": "swagger",
17 | "applicationUrl": "https://localhost:7110;http://localhost:5110",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "IIS Express": {
23 | "commandName": "IISExpress",
24 | "launchBrowser": true,
25 | "launchUrl": "swagger",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/Middleware/SecurityHeadersMiddleware.cs:
--------------------------------------------------------------------------------
1 | namespace ConferenceApi.Infrastructure.Middleware
2 | {
3 |
4 | public class SecurityHeadersMiddleware
5 | {
6 | private readonly RequestDelegate next;
7 |
8 | public SecurityHeadersMiddleware(RequestDelegate next)
9 | {
10 | this.next = next;
11 | }
12 |
13 | public async Task Invoke(HttpContext httpContext)
14 | {
15 | httpContext.Response.Headers.Add("We", "AreAwesome");
16 |
17 | httpContext.Response.Headers.Add("X-Xss-Protection", "1; mode=block");
18 | httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
19 | httpContext.Response.Headers.Add("X-Frame-Options", "DENY");
20 | httpContext.Response.Headers.Add("X-Permitted-Cross-Domain-Policies", "none");
21 |
22 | await this.next.Invoke(httpContext);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi/ConferenceApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi/ConferenceApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Infrastructure/Attributes/CommaQueryStringAttribute.cs:
--------------------------------------------------------------------------------
1 | using Conference.Api.Infrastructure.ValueProviders;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using System;
4 |
5 | namespace Conference.Api.Infrastructure.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
8 | public class CommaQueryStringAttribute : Attribute, IResourceFilter
9 | {
10 | private readonly CommaQueryStringValueProviderFactory factory;
11 |
12 | public CommaQueryStringAttribute()
13 | {
14 | factory = new CommaQueryStringValueProviderFactory();
15 | }
16 |
17 | public void OnResourceExecuted(ResourceExecutedContext context)
18 | {
19 | // will be implemented
20 | }
21 |
22 | public void OnResourceExecuting(ResourceExecutingContext context)
23 | {
24 | context.ValueProviderFactories.Insert(0, factory);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/Attributes/CommaQueryStringAttribute.cs:
--------------------------------------------------------------------------------
1 | using Conference.Api.Infrastructure.ValueProviders;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using System;
4 |
5 | namespace Conference.Api.Infrastructure.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
8 | public class CommaQueryStringAttribute : Attribute, IResourceFilter
9 | {
10 | private readonly CommaQueryStringValueProviderFactory factory;
11 |
12 | public CommaQueryStringAttribute()
13 | {
14 | factory = new CommaQueryStringValueProviderFactory();
15 | }
16 |
17 | public void OnResourceExecuted(ResourceExecutedContext context)
18 | {
19 | // will be implemented
20 | }
21 |
22 | public void OnResourceExecuting(ResourceExecutingContext context)
23 | {
24 | context.ValueProviderFactories.Insert(0, factory);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/Attributes/CommaQueryStringAttribute.cs:
--------------------------------------------------------------------------------
1 | using Conference.Api.Infrastructure.ValueProviders;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using System;
4 |
5 | namespace Conference.Api.Infrastructure.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
8 | public class CommaQueryStringAttribute : Attribute, IResourceFilter
9 | {
10 | private readonly CommaQueryStringValueProviderFactory factory;
11 |
12 | public CommaQueryStringAttribute()
13 | {
14 | factory = new CommaQueryStringValueProviderFactory();
15 | }
16 |
17 | public void OnResourceExecuted(ResourceExecutedContext context)
18 | {
19 | // will be implemented
20 | }
21 |
22 | public void OnResourceExecuting(ResourceExecutingContext context)
23 | {
24 | context.ValueProviderFactories.Insert(0, factory);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/Attributes/CommaQueryStringAttribute.cs:
--------------------------------------------------------------------------------
1 | using Conference.Api.Infrastructure.ValueProviders;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using System;
4 |
5 | namespace Conference.Api.Infrastructure.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
8 | public class CommaQueryStringAttribute : Attribute, IResourceFilter
9 | {
10 | private readonly CommaQueryStringValueProviderFactory factory;
11 |
12 | public CommaQueryStringAttribute()
13 | {
14 | factory = new CommaQueryStringValueProviderFactory();
15 | }
16 |
17 | public void OnResourceExecuted(ResourceExecutedContext context)
18 | {
19 | // will be implemented
20 | }
21 |
22 | public void OnResourceExecuting(ResourceExecutingContext context)
23 | {
24 | context.ValueProviderFactories.Insert(0, factory);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/Attributes/CommaQueryStringAttribute.cs:
--------------------------------------------------------------------------------
1 | using Conference.Api.Infrastructure.ValueProviders;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using System;
4 |
5 | namespace Conference.Api.Infrastructure.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
8 | public class CommaQueryStringAttribute : Attribute, IResourceFilter
9 | {
10 | private readonly CommaQueryStringValueProviderFactory factory;
11 |
12 | public CommaQueryStringAttribute()
13 | {
14 | factory = new CommaQueryStringValueProviderFactory();
15 | }
16 |
17 | public void OnResourceExecuted(ResourceExecutedContext context)
18 | {
19 | // will be implemented
20 | }
21 |
22 | public void OnResourceExecuting(ResourceExecutingContext context)
23 | {
24 | context.ValueProviderFactories.Insert(0, factory);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ch07/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch08/start/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/Conference.Domain/Entities/ConferenceContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | namespace Conference.Domain.Entities;
6 |
7 | public partial class ConferenceContext : DbContext
8 | {
9 | public ConferenceContext()
10 | {
11 | }
12 |
13 | public ConferenceContext(DbContextOptions options)
14 | : base(options)
15 | {
16 | }
17 |
18 | public virtual DbSet Speakers { get; set; }
19 |
20 | public virtual DbSet Talks { get; set; }
21 |
22 |
23 | protected override void OnModelCreating(ModelBuilder modelBuilder)
24 | {
25 | modelBuilder.Entity(entity =>
26 | {
27 | entity.HasIndex(e => e.SpeakerId, "IX_Talks_SpeakerId");
28 |
29 | entity.HasOne(d => d.Speaker).WithMany(p => p.Talks).HasForeignKey(d => d.SpeakerId);
30 | });
31 |
32 | OnModelCreatingPartial(modelBuilder);
33 | }
34 |
35 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
36 | }
37 |
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9 | builder.Services.AddEndpointsApiExplorer();
10 | builder.Services.AddSwaggerGen();
11 |
12 | //builder.Services.Configure(options
13 | // => options.SuppressModelStateInvalidFilter = false);
14 |
15 | //builder.Services.AddProblemDetails(options =>
16 | // options.CustomizeProblemDetails = (context) =>
17 | // {
18 |
19 | // var mathErrorFeature = context.HttpContext.Features.ToArray();
20 |
21 | // });
22 |
23 | var app = builder.Build();
24 |
25 | // Configure the HTTP request pipeline.
26 | if (app.Environment.IsDevelopment())
27 | {
28 | app.UseSwagger();
29 | app.UseSwaggerUI();
30 | }
31 |
32 | app.UseHttpsRedirection();
33 |
34 | app.UseAuthorization();
35 |
36 | app.MapControllers();
37 |
38 | app.Run();
39 |
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9 | builder.Services.AddEndpointsApiExplorer();
10 | builder.Services.AddSwaggerGen();
11 |
12 | //builder.Services.Configure(options
13 | // => options.SuppressModelStateInvalidFilter = false);
14 |
15 | //builder.Services.AddProblemDetails(options =>
16 | // options.CustomizeProblemDetails = (context) =>
17 | // {
18 |
19 | // var mathErrorFeature = context.HttpContext.Features.ToArray();
20 |
21 | // });
22 |
23 | var app = builder.Build();
24 |
25 | // Configure the HTTP request pipeline.
26 | if (app.Environment.IsDevelopment())
27 | {
28 | app.UseSwagger();
29 | app.UseSwaggerUI();
30 | }
31 |
32 | app.UseHttpsRedirection();
33 |
34 | app.UseAuthorization();
35 |
36 | app.MapControllers();
37 |
38 | app.Run();
39 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 |
7 | builder.Services.AddControllers();
8 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9 | builder.Services.AddEndpointsApiExplorer();
10 | builder.Services.AddSwaggerGen();
11 |
12 | //builder.Services.Configure(options
13 | // => options.SuppressModelStateInvalidFilter = false);
14 |
15 | //builder.Services.AddProblemDetails(options =>
16 | // options.CustomizeProblemDetails = (context) =>
17 | // {
18 |
19 | // var mathErrorFeature = context.HttpContext.Features.ToArray();
20 |
21 | // });
22 |
23 | var app = builder.Build();
24 |
25 | // Configure the HTTP request pipeline.
26 | if (app.Environment.IsDevelopment())
27 | {
28 | app.UseSwagger();
29 | app.UseSwaggerUI();
30 | }
31 |
32 | app.UseHttpsRedirection();
33 |
34 | app.UseAuthorization();
35 |
36 | app.MapControllers();
37 |
38 | app.Run();
39 |
--------------------------------------------------------------------------------
/ch08/end/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch09/begin/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch09/end/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch10/begin/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch10/end/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Controllers/AwesomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace ConferenceApi.Controllers
5 | {
6 | [Route("api/[controller]")]
7 | [ApiController]
8 | public class AwesomeController : ControllerBase
9 | {
10 |
11 | //[HttpGet]
12 | //[Route("")]
13 | //[Route("Home")]
14 | //[Route("Home/Index")]
15 | //[Route("Home/Index/{id?}")]
16 | //public IActionResult MyAction(int? id)
17 | //{
18 | // return Ok("Awesome controller-get ");
19 | //}
20 |
21 | [HttpGet]
22 | [Route("")]
23 | [Route("/Home")]
24 | [Route("/Home/Index")]
25 | [Route("/Home/Index/{id?}")]
26 | public IActionResult MyAction2(int? id)
27 | {
28 | return Ok("Awesome controller-get ");
29 | }
30 |
31 | [HttpGet]
32 | [Route("~/")]
33 | public IActionResult MyAction3(int? id)
34 | {
35 | return Ok("Awesome controller-get ");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch04/FirstApi/DIRegistration/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:9151",
7 | "sslPort": 44312
8 | }
9 | },
10 | "profiles": {
11 | "http": {
12 | "commandName": "Project",
13 | "dotnetRunMessages": true,
14 | "launchBrowser": true,
15 | "applicationUrl": "http://localhost:5037",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "https": {
21 | "commandName": "Project",
22 | "dotnetRunMessages": true,
23 | "launchBrowser": true,
24 | "applicationUrl": "https://localhost:7037;http://localhost:5037",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | },
29 | "IIS Express": {
30 | "commandName": "IISExpress",
31 | "launchBrowser": true,
32 | "environmentVariables": {
33 | "ASPNETCORE_ENVIRONMENT": "Development"
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ch11/begin/ConferenceApi/ConferenceApi/Infrastructure/OpenAPi/ConfigureSwaggerOptions.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning.ApiExplorer;
2 | using Microsoft.Extensions.Options;
3 | using Microsoft.OpenApi.Models;
4 | using Swashbuckle.AspNetCore.SwaggerGen;
5 |
6 | namespace ConferenceApi.Infrastructure.OpenAPi
7 | {
8 |
9 | public class ConfigureSwaggerOptions : IConfigureOptions
10 | {
11 | readonly IApiVersionDescriptionProvider provider;
12 |
13 | public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) =>
14 | this.provider = provider;
15 |
16 | public void Configure(SwaggerGenOptions options)
17 | {
18 | foreach (var description in provider.ApiVersionDescriptions)
19 | {
20 | options.SwaggerDoc(
21 | description.GroupName,
22 | new OpenApiInfo()
23 | {
24 | Title = $"Example API {description.ApiVersion}",
25 | Version = description.ApiVersion.ToString(),
26 | });
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Infrastructure/OpenAPi/ConfigureSwaggerOptions.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning.ApiExplorer;
2 | using Microsoft.Extensions.Options;
3 | using Microsoft.OpenApi.Models;
4 | using Swashbuckle.AspNetCore.SwaggerGen;
5 |
6 | namespace ConferenceApi.Infrastructure.OpenAPi
7 | {
8 |
9 | public class ConfigureSwaggerOptions : IConfigureOptions
10 | {
11 | readonly IApiVersionDescriptionProvider provider;
12 |
13 | public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) =>
14 | this.provider = provider;
15 |
16 | public void Configure(SwaggerGenOptions options)
17 | {
18 | foreach (var description in provider.ApiVersionDescriptions)
19 | {
20 | options.SwaggerDoc(
21 | description.GroupName,
22 | new OpenApiInfo()
23 | {
24 | Title = $"Example API {description.ApiVersion}",
25 | Version = description.ApiVersion.ToString(),
26 | });
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Infrastructure/OpenAPi/ConfigureSwaggerOptions.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning.ApiExplorer;
2 | using Microsoft.Extensions.Options;
3 | using Microsoft.OpenApi.Models;
4 | using Swashbuckle.AspNetCore.SwaggerGen;
5 |
6 | namespace ConferenceApi.Infrastructure.OpenAPi
7 | {
8 |
9 | public class ConfigureSwaggerOptions : IConfigureOptions
10 | {
11 | readonly IApiVersionDescriptionProvider provider;
12 |
13 | public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) =>
14 | this.provider = provider;
15 |
16 | public void Configure(SwaggerGenOptions options)
17 | {
18 | foreach (var description in provider.ApiVersionDescriptions)
19 | {
20 | options.SwaggerDoc(
21 | description.GroupName,
22 | new OpenApiInfo()
23 | {
24 | Title = $"Example API {description.ApiVersion}",
25 | Version = description.ApiVersion.ToString(),
26 | });
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Infrastructure/OpenAPi/ConfigureSwaggerOptions.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning.ApiExplorer;
2 | using Microsoft.Extensions.Options;
3 | using Microsoft.OpenApi.Models;
4 | using Swashbuckle.AspNetCore.SwaggerGen;
5 |
6 | namespace ConferenceApi.Infrastructure.OpenAPi
7 | {
8 |
9 | public class ConfigureSwaggerOptions : IConfigureOptions
10 | {
11 | readonly IApiVersionDescriptionProvider provider;
12 |
13 | public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) =>
14 | this.provider = provider;
15 |
16 | public void Configure(SwaggerGenOptions options)
17 | {
18 | foreach (var description in provider.ApiVersionDescriptions)
19 | {
20 | options.SwaggerDoc(
21 | description.GroupName,
22 | new OpenApiInfo()
23 | {
24 | Title = $"Example API {description.ApiVersion}",
25 | Version = description.ApiVersion.ToString(),
26 | });
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ch04/FirstApi/FirstApi/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace FirstApi.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateTime.Now.AddDays(index),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch04/FirstApi/Routing/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace Routing.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace Lifetimes.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch06/end/ConferenceApi/ConferenceApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConferenceApi", "ConferenceApi\ConferenceApi.csproj", "{187FF5A4-4217-47C9-BD34-C9E4FBB0616B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {638E849A-5E4C-4B6E-8297-D5599D7550A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace ConferenceApi.Controllers
4 | {
5 | [ApiController]
6 | [Route("[controller]")]
7 | public class WeatherForecastController : ControllerBase
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | private readonly ILogger _logger;
15 |
16 | public WeatherForecastController(ILogger logger)
17 | {
18 | _logger = logger;
19 | }
20 |
21 | [HttpGet(Name = "GetWeatherForecast")]
22 | public IEnumerable Get()
23 | {
24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 | {
26 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 | TemperatureC = Random.Shared.Next(-20, 55),
28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 | })
30 | .ToArray();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/ch06/start/ConferenceApi/ConferenceApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConferenceApi", "ConferenceApi\ConferenceApi.csproj", "{187FF5A4-4217-47C9-BD34-C9E4FBB0616B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {638E849A-5E4C-4B6E-8297-D5599D7550A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ch07/start/ConferenceApi/ConferenceApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConferenceApi", "ConferenceApi\ConferenceApi.csproj", "{187FF5A4-4217-47C9-BD34-C9E4FBB0616B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {638E849A-5E4C-4B6E-8297-D5599D7550A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ch05/starting_point/ConferenceApi/ConferenceApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConferenceApi", "ConferenceApi\ConferenceApi.csproj", "{187FF5A4-4217-47C9-BD34-C9E4FBB0616B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {638E849A-5E4C-4B6E-8297-D5599D7550A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ch06/scaffold_project/ConferenceApi/ConferenceApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConferenceApi", "ConferenceApi\ConferenceApi.csproj", "{187FF5A4-4217-47C9-BD34-C9E4FBB0616B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {187FF5A4-4217-47C9-BD34-C9E4FBB0616B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {638E849A-5E4C-4B6E-8297-D5599D7550A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ch11/end/ConferenceApi/ConferenceApi/Controllers/SpeakersControllerV2.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning;
2 | using AutoMapper;
3 | using Conference.Domain.Entities;
4 | using Conference.Service;
5 | using ConferenceApi.Models;
6 | using Microsoft.AspNetCore.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 |
9 | namespace ConferenceApi.Controllers
10 | {
11 | [Route("api/speakers")]
12 | [ApiVersion("2.0")]
13 | [ApiController]
14 | public class SpeakersControllerV2 : ControllerBase
15 | {
16 | private readonly ISpeakersService speakersService;
17 | private readonly IMapper mapper;
18 |
19 | public SpeakersControllerV2(ISpeakersService speakersService, IMapper mapper)
20 | {
21 | this.speakersService = speakersService;
22 | this.mapper = mapper;
23 | }
24 |
25 |
26 | [HttpGet("{id}", Name ="GetSpeakerById2")]
27 | public ActionResult GetSpeakerByIdV2(int id)
28 | {
29 | var speakerToReturn = speakersService.Get(id);
30 | if (speakerToReturn == null)
31 | {
32 | return NotFound();
33 | }
34 | return Ok(mapper.Map(speakerToReturn));
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch12/end/ConferenceApi/ConferenceApi/Controllers/SpeakersControllerV2.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning;
2 | using AutoMapper;
3 | using Conference.Domain.Entities;
4 | using Conference.Service;
5 | using ConferenceApi.Models;
6 | using Microsoft.AspNetCore.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 |
9 | namespace ConferenceApi.Controllers
10 | {
11 | [Route("api/speakers")]
12 | [ApiVersion("2.0")]
13 | [ApiController]
14 | public class SpeakersControllerV2 : ControllerBase
15 | {
16 | private readonly ISpeakersService speakersService;
17 | private readonly IMapper mapper;
18 |
19 | public SpeakersControllerV2(ISpeakersService speakersService, IMapper mapper)
20 | {
21 | this.speakersService = speakersService;
22 | this.mapper = mapper;
23 | }
24 |
25 |
26 | [HttpGet("{id}", Name ="GetSpeakerById2")]
27 | public ActionResult GetSpeakerByIdV2(int id)
28 | {
29 | var speakerToReturn = speakersService.Get(id);
30 | if (speakerToReturn == null)
31 | {
32 | return NotFound();
33 | }
34 | return Ok(mapper.Map(speakerToReturn));
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch12/begin/ConferenceApi/ConferenceApi/Controllers/SpeakersControllerV2.cs:
--------------------------------------------------------------------------------
1 | using Asp.Versioning;
2 | using AutoMapper;
3 | using Conference.Domain.Entities;
4 | using Conference.Service;
5 | using ConferenceApi.Models;
6 | using Microsoft.AspNetCore.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 |
9 | namespace ConferenceApi.Controllers
10 | {
11 | [Route("api/speakers")]
12 | [ApiVersion("2.0")]
13 | [ApiController]
14 | public class SpeakersControllerV2 : ControllerBase
15 | {
16 | private readonly ISpeakersService speakersService;
17 | private readonly IMapper mapper;
18 |
19 | public SpeakersControllerV2(ISpeakersService speakersService, IMapper mapper)
20 | {
21 | this.speakersService = speakersService;
22 | this.mapper = mapper;
23 | }
24 |
25 |
26 | [HttpGet("{id}", Name ="GetSpeakerById2")]
27 | public ActionResult GetSpeakerByIdV2(int id)
28 | {
29 | var speakerToReturn = speakersService.Get(id);
30 | if (speakerToReturn == null)
31 | {
32 | return NotFound();
33 | }
34 | return Ok(mapper.Map(speakerToReturn));
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ch04/FirstApi/Lifetimes/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:15255",
8 | "sslPort": 44347
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "launchUrl": "swagger",
17 | "applicationUrl": "http://localhost:5056",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "https": {
23 | "commandName": "Project",
24 | "dotnetRunMessages": true,
25 | "launchBrowser": true,
26 | "launchUrl": "swagger",
27 | "applicationUrl": "https://localhost:7041;http://localhost:5056",
28 | "environmentVariables": {
29 | "ASPNETCORE_ENVIRONMENT": "Development"
30 | }
31 | },
32 | "IIS Express": {
33 | "commandName": "IISExpress",
34 | "launchBrowser": true,
35 | "launchUrl": "swagger",
36 | "environmentVariables": {
37 | "ASPNETCORE_ENVIRONMENT": "Development"
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------