main
|
Last change
on this file since b62cefc was 877c13c, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago |
|
Added files
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | using ChapterX.Domain.Repositories;
|
|---|
| 2 | using MediatR;
|
|---|
| 3 | using Microsoft.Extensions.Logging;
|
|---|
| 4 |
|
|---|
| 5 | namespace ChapterX.Application.Notify.Commands
|
|---|
| 6 | {
|
|---|
| 7 | public class UpdateHandler : IRequestHandler<UpdateRequest, UpdateResponse>
|
|---|
| 8 | {
|
|---|
| 9 | private readonly INotifyRepository _notifyRepository;
|
|---|
| 10 | private readonly ILogger<UpdateHandler> _logger;
|
|---|
| 11 |
|
|---|
| 12 | public UpdateHandler(INotifyRepository notifyRepository, ILogger<UpdateHandler> logger)
|
|---|
| 13 | {
|
|---|
| 14 | _notifyRepository = notifyRepository;
|
|---|
| 15 | _logger = logger;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | public async Task<UpdateResponse> Handle(UpdateRequest request, CancellationToken cancellationToken)
|
|---|
| 19 | {
|
|---|
| 20 | var notify = await _notifyRepository.GetByIdAsync(request.Id, cancellationToken);
|
|---|
| 21 | if (notify is null)
|
|---|
| 22 | return new UpdateResponse(false);
|
|---|
| 23 |
|
|---|
| 24 | // No updatable fields on Notify entity
|
|---|
| 25 |
|
|---|
| 26 | await _notifyRepository.UpdateAsync(notify, cancellationToken);
|
|---|
| 27 |
|
|---|
| 28 | return new UpdateResponse(true);
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.