chanhi2000 / Commander

.NET Core 3.1 MVC REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.Net Core 3.1 MVC REST API

PART 1 - FIRST 2 API ENDPOINTS (GET / READ)

  • v0.0.1 : Project Setup
  • v0.0.2 : Create our Domain Model (Command)
  • v0.0.3 : Build Our Repository Interface
  • v0.0.4 : Implement our Repository Interface (Mock Reposiory)
  • v0.0.5 : Create our Controller (CommandsController)
  • v0.0.6 : Create 2x API Endpoints
  • v0.0.6 : Using Dependency Injection

PART 2 - ENTITY FRAMEWORK & SQL SERVER

  • Architecture Checkpoint
  • Set Up SQL Server App Login
  • v0.1.0 : En tityframework Packages
  • Entityframework Toolset
  • v0.1.1 : Create our Database Context (CommanderContext)
  • v0.1.2 : Our Database Connecttion String
  • v0.1.3 : Register our DB Context in Startup
  • Create Migrations
  • Cancel Migrations & revist Command Model
  • v0.1.4 : Add Data Validations to Command Model
  • Create Migrations (Again!)
  • Run Migrations against Database
  • Add Data to Database
  • v0.1.5 : Revist Our Repository to use DB Context

PART 3 - DATA TRANSFER OBJECTS & CREATE ENDPOINT

  • Architecture Checkpoint
  • Why Data Transfer Objects?
  • v0.2.0 : AutoMapper Package & Startup Registration
  • v0.2.1 : Create our first DTO
  • v0.2.2 : Creating a mapping Profile
  • v0.2.3 : Updating Our Action Results to use DTOs

PART 4 - PUT, PATCH & DELETE API ENDPOINTS

  • Architecture Checkpoint
  • v0.3.0 : Updating our Repository for Creating Resources
  • v0.3.1 : Create a New DTO (for Creating)
  • v0.3.2 : Create 3rd API Endpoint to Create Resources
  • v0.3.3 : Use CreatedAtRoute to return 201 CreatedAtRoute
  • v0.3.4 : Add Annotations to DTO to avoid 500 Errors
  • v0.3.5 : Update Repository to Support Updates
  • v0.3.6 : Add a New DTO (for Updating)
  • v0.3.7 : Add 4th API Endpoint for Updating (PUT Request)
  • v0.3.7 : Update our AutoMapper Profile
  • Overview of PATCH
  • v0.3.8 : Install 2x packages to support PATCH
  • v0.3.9 : Update Startup
  • v0.3.10 : Update our AutoMapper Profile (Final Update)
  • v0.3.11 : Add 5th API Endpoint for Updating (PATCH Request)
  • v0.3.12 : Add 6th API Endpoint for Deleting (DELETE Request)

Build & Run

  • run the following commands
dotnet run

Entityframework Toolset : dotnet-ef

  • to install
dotnet tool install --global dotnet-ef
  • to create migrations
dotnet ef migrations add InitialMigration
  • to undo migrations
dotnet ef migrations remove
  • to run update on database
dotnet ef database update

Note

  • Run following query for Enable Insert Then Disable
set IDENTITY_INSERT Commands ON;
...
/*ADD DATA HERE*/
...
set IDENTITY_INSERT Commands OFF;

Endpoint to Test

  • /api/commands/
  • /api/commands/{id}

Reference

About

.NET Core 3.1 MVC REST API


Languages

Language:C# 100.0%