-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathCategoryModule.cs
More file actions
45 lines (43 loc) · 1.75 KB
/
CategoryModule.cs
File metadata and controls
45 lines (43 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Carter;
using Category.Domain;
using Category.Features.Create.v1;
using Category.Features.Delete.v1;
using Category.Features.Get.v1;
using Category.Features.GetList.v1;
using Category.Features.Update.v1;
using Category.Persistence;
using FSH.Framework.Core.Persistence;
using FSH.Framework.Infrastructure.Persistence;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace Category;
public static class CategoryModule
{
public class Endpoints : CarterModule
{
public override void AddRoutes(IEndpointRouteBuilder app)
{
var categoryItemGroup = app.MapGroup("categoryItems").WithTags("categoryItems");
categoryItemGroup.MapCategoryItemCreationEndpoint();
categoryItemGroup.MapGetCategoryItemEndpoint();
categoryItemGroup.MapGetCategoryItemListEndpoint();
categoryItemGroup.MapCategoryItemUpdationEndpoint();
categoryItemGroup.MapCategoryItemDeletionEndpoint();
}
}
public static WebApplicationBuilder RegisterCategoryItemServices(this WebApplicationBuilder builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.Services.BindDbContext<CategoryItemDbContext>();
builder.Services.AddScoped<IDbInitializer, CategoryItemDbInitializer>();
builder.Services.AddKeyedScoped<IRepository<CategoryItem>, CategoryItemRepository<CategoryItem>>("categoryItem");
builder.Services.AddKeyedScoped<IReadRepository<CategoryItem>, CategoryItemRepository<CategoryItem>>("categoryItem");
return builder;
}
public static WebApplication UseCategoryItemModule(this WebApplication app)
{
return app;
}
}