Skip to content

Get started

anton-martyniuk edited this page Aug 29, 2022 · 2 revisions

First, select and install the needed Nuget packages !!!
Lets consider the following example: repository, service and controller. Install the following Nuget packages:

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

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