
Set up a clean asp.net core 8 web api for dev and prod azure. Connect azure sql, application insights, blob storage; enable identity, roles, restaurant and dish management.
Explore http basics, client-server communication, and rest api concepts; set up your local environment, create an empty dotnet web api, and practice routing, model binding, and a simple http client.
Explore the HTTP protocol as the foundation of web data exchange, covering stateless requests, status codes, cacheability, headers, request bodies, and verbs (get, post, put, patch, delete) with YouTube-style examples.
Discover what an API and REST are, how REST uses HTTP methods and endpoints to manage resources, and REST design principles for building a RESTful API with .NET.
Create a new web api project with dotnet cli, name it Restaurants.API, scaffold a solution, add the project to it, and run the default weather forecast endpoint returning json.
Set up a dotnet eight web api project, configure launch settings, and register controllers. Test the weather forecast endpoint with routing and api prefix using the built-in http file.
Learn to build HTTP requests in ASP.NET Core Web API using Visual Studio REST client. Explore variables, headers, and JSON bodies, and generate requests from the endpoints explorer window.
Explore how ASP.NET Core 8 Web API routes requests to controller actions and uses model binding to supply parameters from body, query, route, or header.
Learn how ASP.NET Core returns status codes, from informational 100 to server errors, and how to override defaults using direct response status, status code results, or dedicated action results.
Create and test the first endpoint that generates weather data by posting a count and temperature range, validating input and returning 200 ok or 400 bad request.
Add domain, application, and infrastructure modules to a clean architecture solution, linking domain models like restaurants and addresses to the application use cases and the API presentation layer.
Create a base restaurant entity in the domain module with address and dish entities, defining name, description, category, delivery, and a dishes collection with id and price.
Map C# classes to database tables with entity framework, using a db context and dbset to query with linq instead of sql, and switch providers without code changes.
Install and configure Entity Framework Core to connect your web API to a SQL Server database. Define restaurants and dishes db sets, owned address, and migrations for schema.
Register the RestaurantsDBContext in the DI container via an infrastructure extension, fetch the environment-specific connection string from application settings, and configure EF Core with sql server.
Extend the dish entity with a nullable int KiloCalories, scaffold and apply a migration, and verify the new column exists in the dishes table after updating the database.
Enable the API to retrieve resources under REST, map database entities to DTOs containing only the information for API clients, and create a resource endpoint with validation using Fluent Validation.
Learn to implement the get all restaurants flow: build a restaurants controller, an application service, and repository with dependency injection, enabling an api endpoint /api/restaurants that returns data asynchronously.
Learn how to replace manual mapping with AutoMapper in ASP.NET Core 8 Web API by creating profiles, configuring ForMember mappings for nested properties, and registering AutoMapper in dependency injection.
The name of this package has changed to just "Automapper" - if you did install it, as it was in the video just change the package in your Restaurants.Application.csproj:
from
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
to
<PackageReference Include="AutoMapper" Version="13.0.1" />
it has no breaking changes
Demonstrates read and create operations in an ASP.NET Core 8 Web API: retrieve all or by id, create a restaurant using a create restaurant dto and AutoMapper, returning 201 created.
Demonstrates implementing fluent validation for CreateRestaurantDto, replacing attributes with a dedicated validator, configuring DI, and defining rules for name, description, category, email, phone, and postal code.
Introduce command query responsibility segregation with the mediator package, organizing work into queries and commands. Learn how queries fetch data without state changes, while commands modify state without returning resources.
Learn how to apply cqrs in a dotnet web api by separating writing commands from reading queries using MediatR, with handlers and registering in service collection.
Learn how to implement a delete restaurant endpoint using CQRS with MediatR, creating a delete command and handler, checking existence, and returning 204 no content or 404 not found.
Implement a patch endpoint at /api/restaurant/{id} to update a restaurant name, description, and hasDelivery; return 204 on success, 404 if not found, via mediator command with validation and automapper.
Implement structured logging in a .NET 8 web API using Serilog, configuring log levels, sinks, formats, enrichers, and EF Core logging for production troubleshooting.
Extend Serilog logging by adding a file sink with daily rolling and size-based rollover, configured via appsettings development json, while preserving console output for endpoints like get all restaurants.
Implement a global exception handling middleware in an ASP.NET Core web API to catch errors, log them, and return a generic 500 response instead of exposing internal details.
Replace boolean existence checks with a custom not found exception across commands and queries. Configure error handling middleware to translate not found exceptions into 404 responses and log the event.
Create a time logging middleware for asp.net core 8 web api using IMiddleware and Stopwatch to log the http verb, path, and elapsed time only when it exceeds four seconds.
Adapt endpoint structure to match rest api guidelines, enabling creation, retrieval, and removal of restaurant subresources.
Define nested rest endpoints for dishes under /api/restaurant/{restaurantId}/dishes to reflect the restaurant–dish relationship and support not found handling for non-matching dishes.
Implement endpoints to retrieve all dishes for a restaurant and a single dish by id, using mediator queries, dish dto mapping, and proper not-found handling.
Implement a delete endpoint to remove all dishes for a restaurant's sub-entities, using a mediator command and handler, returning 404 if the restaurant is missing, and 204 on success.
Enable the dishes controller to return a 201 created response with a proper location header. Use CreatedAtAction to point to GetByIdForRestaurant with the restaurant id and the new dish id.
Introduce authentication by setting up identity infrastructure, extending the database with identity tables, and exposing endpoints for account creation and login. Enforce access with the authorize attribute to protect endpoints.
Configure the asp.net core identity package with entity framework core to manage users and roles, expose register, login, and password reset endpoints, and integrate with a custom user class.
Enable swagger to expose identity endpoints for minimal API by configuring endpoints API explorer, add a bearer token security definition, authorize in swagger, and prefix identity routes with /api/identity.
Refactor the web api startup by extracting presentation layer services into a WebApplicationBuilder extension, preserving swagger and identity endpoints while cleaning up program.cs.
Enable user authentication by adding authentication services and authorization middleware, obtain an access token from the identity login endpoint, and use it as a bearer token to authorize requests.
Learn to pass authenticated user context into the application layer by building a current user model from claims, via a reusable user context service and http context accessor.
Extend the identity user by adding date of birth and nationality, apply a migration, update the identity dbcontext and endpoints, and implement a patch to update these properties via mediator.
Introduce authorization after authentication by implementing role-based access control with three roles and identity role support, then add custom claims and enforce resource ownership for deletions and modifications.
Discover how authorization grants or denies access to web API resources based on user identity, roles, or permissions. Compare role-based, attribute-based, and resource-based access control to secure and personalize applications.
Define and seed roles (user, owner, admin) for an ASP.NET Core 8 API, configure role-based authorization with claims, and enforce access using the authorize attribute on endpoints.
Develop an admin-only endpoint in the identity controller to assign a user to a role using the mediator pattern, with user manager and role manager checks and 404 handling.
Create a delete endpoint in the identity controller to unassign a user role, accessible only to admins, with a handler that returns 404 if not found and 204 on success.
Extend the default user claims by implementing a custom user claims principal factory, adding nationality and date of birth, with role manager to support attribute-based access control.
Define the has nationality policy using a custom authorization builder. Apply the policy to endpoints to enforce nationality claim existence or value-based access control.
Define a custom authorization requirement for minimum age, implement its handler using the date of birth claim, register it, and apply an at least 20 policy to secure endpoints.
Configure a one-to-many relationship between users and restaurants by adding an owner id and foreign key, migrate the database, and set the current user as the restaurant owner on creation.
Implement resource-based authorization for restaurants using a centralized restaurant authorization service that handles create, read, update, and delete operations with owner and admin checks, and returns 403 forbidden when unauthorized.
Create a custom authorization policy requiring a user to own at least two restaurants, register the handler in DI, and apply it to the get all restaurants endpoint.
Master Clean Architecture & Azure for Scalable APIs in ASP.NET Core 8
Ready to build robust, high-performance RESTful APIs with confidence? This comprehensive course empowers you with the knowledge and skills to create modern web APIs using the powerful combination of ASP.NET Core 8, Clean Architecture, and Azure services.
Your journey begins with understanding the fundamentals:
RESTful API essentials: Demystify HTTP communication, grasp REST principles, and set up your local development environment.
ASP.NET Core 8 mastery: Dive into routing, model binding, and HTTP client usage to build the foundation of your API.
Clean Architecture adoption: Learn the benefits and principles of Clean Architecture, and apply them to structure your API for maintainability and flexibility.
Next, you'll establish the infrastructure:
Database connection with Entity Framework: Set up your MS SQL database and leverage Entity Framework for seamless data interaction.
Seeding mechanism: Populate your database with essential data for realistic testing and functionality.
Ready to build features? Buckle up!
RESTful resource management: Create, retrieve, update, and delete resources following REST best practices.
DTO mapping and validation: Ensure data integrity and security with efficient mapping and Fluent Validation.
Command/Query Responsibility Segregation: Organize your code with a clear separation of concerns using MediatR.
More than just features - enhance your API's robustness:
Logging with Serilog: Track API events for troubleshooting and maintainability.
Automated documentation: Generate clear API documentation for easy client integration.
Global exception handling: Gracefully handle errors and provide informative feedback to clients.
Deep dive into advanced topics:
Sub-entity management: Handle nested resources within your main entities with proper RESTful structure.
User authentication and authorization: Secure your API with user accounts, roles, and custom claims using ASP.NET Identity.
Pagination and sorting: Optimize performance for large datasets with pagination and sorting capabilities.
Testing and deployment are crucial:
Automated unit and integration tests: Ensure code quality and prevent regressions with comprehensive testing strategies.
Azure deployment: Leverage Azure App Service and Azure SQL to deploy your API to a scalable cloud environment.
CI/CD pipelines: Automate deployment processes for efficient updates and bug fixes.
By the end of this course, you'll be equipped to:
Architect and build secure, maintainable, and scalable RESTful APIs.
Confidently leverage Clean Architecture principles for code organization.
Utilize powerful Azure services for deployment and scalability.
Implement best practices for performance, logging, testing, and documentation.
Enroll now and take your .NET WEB API development skills to the next level!