0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-07-01 02:52:56 +00:00
CleanArchitecture/CleanArchitecture.Domain/Extensions/ServiceCollectionExtension.cs
2023-03-08 22:40:09 +01:00

32 lines
1.2 KiB
C#

using CleanArchitecture.Domain.Commands.Users.CreateUser;
using CleanArchitecture.Domain.Commands.Users.DeleteUser;
using CleanArchitecture.Domain.Commands.Users.UpdateUser;
using CleanArchitecture.Domain.EventHandler;
using CleanArchitecture.Domain.Events.User;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
namespace CleanArchitecture.Domain.Extensions;
public static class ServiceCollectionExtension
{
public static IServiceCollection AddCommandHandlers(this IServiceCollection services)
{
// User
services.AddScoped<IRequestHandler<CreateUserCommand>, CreateUserCommandHandler>();
services.AddScoped<IRequestHandler<UpdateUserCommand>, UpdateUserCommandHandler>();
services.AddScoped<IRequestHandler<DeleteUserCommand>, DeleteUserCommandHandler>();
return services;
}
public static IServiceCollection AddNotificationHandlers(this IServiceCollection services)
{
// User
services.AddScoped<INotificationHandler<UserCreatedEvent>, UserEventHandler>();
services.AddScoped<INotificationHandler<UserUpdatedEvent>, UserEventHandler>();
services.AddScoped<INotificationHandler<UserDeletedEvent>, UserEventHandler>();
return services;
}
}