1
This commit is contained in:
30
Yes.Application/Admins/Themes/UpdateThemeCommandHandler.cs
Normal file
30
Yes.Application/Admins/Themes/UpdateThemeCommandHandler.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace Yes.Application.Admins.Themes
|
||||
{
|
||||
public record UpdateThemeCommand(
|
||||
string Theme
|
||||
) : IRequest<Unit>;
|
||||
|
||||
|
||||
public class UpdateThemeCommandHandler(
|
||||
IOptionsMonitor<BlogSettings> options,
|
||||
IMapper mapper,
|
||||
IThemeService themeService,
|
||||
IConfigurationService configurationService
|
||||
) : IRequestHandler<UpdateThemeCommand, Unit>
|
||||
{
|
||||
private readonly BlogSettings _settings = options.CurrentValue;
|
||||
private readonly IMapper _mapper = mapper;
|
||||
private readonly IThemeService _themeService = themeService;
|
||||
private readonly IConfigurationService _configurationService = configurationService;
|
||||
public async Task<Unit> Handle(UpdateThemeCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
_themeService.CheckThemeExists(request.Theme);
|
||||
|
||||
_mapper.Map(request, _settings);
|
||||
|
||||
await _configurationService.SaveConfiguration(_settings);
|
||||
|
||||
return new Unit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user