Skip to content

Get started

anton-martyniuk edited this page Feb 13, 2023 · 2 revisions

To build a complete CRUD Api install the following Nuget packages:

  • Modern.Repositories.EFCore.DependencyInjection
  • Modern.Services.DataStore.DependencyInjection
  • Modern.Controllers.DataStore.DependencyInjection

Create entities, mapping, EF Core DbContexts and models for the API.
No need to create a repositories, services, controllers or CQRS queries and commands.
All these will be created by Modern tools.

Register the Modern builder in DI and add the following components:

builder.Services
    .AddModern()
    .AddRepositoriesEfCore(options =>
    {
        options.AddRepository<FlyingDbContext, AirplaneDbo, long>();
    })
    .AddServices(options =>
    {
        options.AddService<AirplaneDto, AirplaneDbo, long, IModernRepository<AirplaneDbo, long>>();
    })
    .AddControllers(options =>
    {
        options.AddController<CreateRequest, UpdateRequest, AirplaneDto, AirplaneDbo, long>();
    });

As a result a production ready API will be created:

GET 🔵
/Airplanes/get/{id}

GET 🔵 🔵
/Airplanes/get

POST
/Airplanes/create

POST ✅ ✅
/Airplanes/create-many

PUT 〽️
/Airplanes/update/{id}

PUT 〽️ 〽️
/Airplanes/update-many

PATCH 💲
/Airplanes/patch/{id}

DELETE
/Airplanes/delete/{id}

DELETE ❌ ❌
/Airplanes/delete-many

Clone this wiki locally