
Build a multi-layer .NET Core 3.1 web API from scratch, implementing repository pattern, entity framework core, automapper, and jwt security across data, business, and presentation layers.
Prepare your development environment by installing Visual Studio 2019 Community and the .NET Core 3.1 SDK, then install and start MongoDB to connect your multi-layer .NET Core 3.1 web API.
Prepare by mastering basic C# oriented concepts and .NET Core 3.1, and review MVC web application fundamentals to continue building a multi-layer .NET core 3.1 web API.
Understand what a web api is and why we need it, as it uses http, supports restful access, endpoints, and can be consumed by any application across languages.
Create a global multi-layer net core 3.1 solution skeleton, with a backend api, core, services, and data layers, plus a web client using mvc, angular, or react.
Download the project.zip to access the multi-layer .NET Core 3.1 Web API from zero and begin exploring the code.
Build the core layer, design models and classes, implement repository interfaces, and explore the benefits of repositories while outlining the interactions among API, business logic, and data access layers.
Create two model classes, music and artist, for the application's core. Define properties id, name, artistId, and a collection of musics per artist, and include System.Collections.
Explore the repository pattern and unit of work to centralize data access, enabling reusable CRUD operations, testable with mocks, and separation of concerns across music and artist entities.
Define interface services as the center of business logic, linking the API and data through music and artist services, with repositories, unit of work, and the core layer.
Download the project.zip to start building the multi-layer .NET Core 3.1 web API from zero.
Introduce building a multi-layer .NET Core 3.1 web API from zero by setting up repositories, configuring dependency injection in startup, and creating the database for the API project.
Configure sql server with entity framework core to build the data layer, mapping database tables to c# objects, and install the required nuget packages and tools.
Create and configure music and artist configuration classes, defining properties, required fields, max lengths, foreign keys, and one-to-many relationships between music and artists.
Define the DbContext with DbSet properties for Music and Artist, implement the constructor and OnModelCreating to apply Music and Artist configurations, and set up dependency injection.
Implement the repository pattern by building concrete repositories for music and artist, define the DB context, and enable asynchronous CRUD operations with a unit of work and dependency injection.
Implement dependency injection in a .NET Core 3.1 web API by configuring startup, adding project references, and defining scoped services with EF Core.
Create and apply a database using add-migration for my music API, generate tables for artist and music with primary and foreign keys, and verify the local database in SQL Server.
Initialize the database with seed data by creating and populating the music and artist tables, saving changes, and verifying the inserted records. Prepare for the next section with MongoDB.
Download the project.zip to begin building a multi-layer .NET Core 3.1 web API from zero.
Explore the multi-layer architecture by examining the access layer, implementing a repository, and applying dependency injection for data access in a .NET Core 3.1 Web API.
Explore MongoDB, an open source document database written in C++, cross platform, offering high performance and high availability through collections of documents and key-value data.
Introduce a MongoDB data layer by adding a public composer class (id as ObjectId, first name, last name), and implement IComposerRepository and IComposerService to manage composers.
Configure the project for MongoDB by adding the driver, creating a settings class with connection string and database, and enabling dependency injection for the composer collection.
Integrate dependency injection for MongoDB in your .NET Core Web API by configuring startup, setting the MongoDB connection string, registering the driver, and creating a repository for database operations.
Build a MongoDB composer repository with dependency injection, configure the database, and implement create, get all, get by id, and delete operations in a .NET Core 3.1 Web API.
Download the project.zip to begin building a multi-layer .NET Core 3.1 Web API from zero.
Learn to build a multi-layer .NET Core 3.1 web api by wiring the api layer to the business layer and data layer through interfaces, with a mongo db context.
Create three-layer services for music, artist, and composer with unit of work and repositories, then configure dependency injection and wire them into the web API.
Download the project.zip to explore a multi-layer .NET Core 3.1 Web API architecture and implementation details.
Create a restful api layer that follows rest architecture, ensuring stateless client-server communication, a uniform interface, and standard resource operations using get, post, put, and delete.
Install the Swagger library, configure services and startup to enable Swagger in a .NET Core 3.1 Web API, and run on localhost to view the API documentation.
Create and configure multiple API controllers in a .NET core 3.1 project, including music, artist, and composer controllers, and troubleshoot by recreating the solution.
Create a GetAllMusic method in a multi-layer .NET Core 3.1 Web API by injecting the music service into the controller and returning all music with artist details.
Map domain models to resource views with AutoMapper in a .NET Core 3.1 Web API, create music and artist resources, configure mapping profiles, and expose a get music endpoint.
Create the get music by id endpoint in a multi-layer .NET Core 3.1 web API, define music service and music resource, return name and artist, and handle not found responses.
Build a multi-layer .NET Core 3.1 Web API from zero by creating the create music endpoint, validating data with a save music resource validator, and mapping to persist music.
Define the validator, validate input, fetch music by id, return not found if missing, map updated data, and perform the update with a put operation.
Create the delete music API method in the .NET Core 3.1 web API and test deleting a music entry, then verify not found when retrieving it.
Create a get all music by artist by id endpoint in a multi-layer .NET core 3.1 web api, inject the artist service, and map music to a music resource.
Create the api GetAllArtist method in the artist controller using dependency injection, map artists, and test returning all artists.
Create a get artist by id API method, handle not found, map the artist to a resource, and test retrieval with ids in a multi-layer .NET Core 3.1 Web API.
Define the artist class and save artist resource with name validation, then map to domain and expose create and get by id via a service.
Create the API update artist endpoint in a .NET Core 3.1 Web API, validate the save artist resource, and update and retrieve the artist by id.
Create the delete artist API method in a multi-layer .NET Core 3.1 Web API, test by retrieving artists, deleting an artist, and confirming the artist is removed.
Implement a GetAllComposer endpoint in a multi-layer .NET Core 3.1 Web API, wiring up dependency injection, a composer resource and mapping, and retrieving all composers from MongoDB.
Create a .NET Core 3.1 web API endpoint to add a composer by validating first and last names, mapping to a composer resource, and saving to MongoDB.
Create a GetComposerById endpoint in a .NET Core 3.1 Web API, wiring a MongoDB database, return the composer by id or not found, and test the get operation.
Recap of the API layer in the backend, detailing resource mapping, validation, and layered data, and a preview of the next section on authentication.
Download the project zip to access the ready-to-run .NET Core 3.1 Web API, enabling you to explore the multi-layer architecture from zero.
Learn how to implement JWT authentication in a .NET Core 3.1 Web API, including issuing tokens, sending them in the header, and validating header and signature across front-end and back-end.
Install JWT-based authentication, configure app settings, and build a user model, repository, and service with authentication, account creation, and user updates and deletions.
Update the data layer by adding a public user configuration implementing IEntityTypeConfiguration, integrating the user into the DbContext, creating migrations, and building a user repository with authentication and password hashing.
Implement the data layer user service with unit of work, adding authenticate, create, delete, and get operations to support the next music API controller.
Develop a user API in a .NET core 3.1 project by configuring startup, injecting user services, implementing register and authentication endpoints, and issuing JWT tokens.
Download the project.zip to explore a multi-layer NET Core 3.1 Web API from zero in a hands-on way.
Begin building a multi-layer .net core 3.1 web api from zero by creating the backend, then crafting the frontend to consume different endpoint api and get started.
Create a client project with ASP.NET Core MVC 3.1 web application model view controller, link a backend web API, and build a front-end web client to consume it.
Configure the web API address and fetch the music list from the backend. Define a music model with id, name, and artist, and display them in the index view.
Build a music view model and add music to the database by posting JSON content through the home controller to the .NET core 3.1 web API, then display music list.
Display the list of composers in an MVC app by defining a composer model with first and last names, enabling dependency injection, and rendering the index view from MongoDB.
Implement authentication in ASP.NET Core MVC to consume Web API authentication, wiring a login flow with a login view and view model, and manage JWT tokens and session.
Create a registration form for a new user, define a public user model with first name, last name, username, and password, validate inputs, and post to register.
Implement authorization for a .NET Core 3.1 web API by requiring a JWT token in the request header, validating it in the backend, and securing the add music endpoint.
Create a new composer in the multi-layer .NET Core 3.1 web API by defining a composer model with required first and last names and implementing the create view and actions.
Learn how to retrieve the current user in a .NET Core 3.1 web api using identity in the backend, with logging to verify user identity for application processing.
Download the project.zip to access a multi-layer .NET Core 3.1 web API from Zero and study its structure.
Hello,
I decided to create this course because I actually couldn’t find many courses explaining on how to separate your application in multiple layers with ASP.NET Core 3.1 Web API.
Here we are building a nice API with basic CRUD (Create, Read, Update, Delete) operations. It will be an API for an app that stores which musics you like with its artists.
I will show you how to:
· Create an application in separated projects to make it decoupled from each module.
· Implement Repository and Unit of Work pattern.
· Use Entity Framework Core for persistence with SQL server.
· Use MongoDB Database for NoSQL
· Add AutoMapper for mapping models into API resources.
· Add Swagger to have a friendly API interface.
· Integrate the Authentication & Authorization with JWT (JSON Web Token)
· Application Client with ASP.NET CORE MVC to consume the APIs
And on top of all these, you'll get:
Download the source code