main
|
Last change
on this file since e882b92 was e882b92, checked in by kikisrbinoska <srbinoskakristina07@…>, 13 days ago |
|
Added corrected entitef from the ER diagram and changes for the logic to be coresponding to the ddl
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [877c13c] | 1 | using ChapterX.Domain.Repositories;
|
|---|
| 2 | using MediatR;
|
|---|
| 3 | using Microsoft.Extensions.Logging;
|
|---|
| 4 |
|
|---|
| 5 | namespace ChapterX.Application.Notification.Commands
|
|---|
| 6 | {
|
|---|
| 7 | public class AddHandler : IRequestHandler<AddRequest, AddResponse>
|
|---|
| 8 | {
|
|---|
| 9 | private readonly INotificationRepository _notificationRepository;
|
|---|
| 10 | private readonly ILogger<AddHandler> _logger;
|
|---|
| 11 |
|
|---|
| 12 | public AddHandler(INotificationRepository notificationRepository, ILogger<AddHandler> logger)
|
|---|
| 13 | {
|
|---|
| 14 | _notificationRepository = notificationRepository;
|
|---|
| 15 | _logger = logger;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | public async Task<AddResponse> Handle(AddRequest request, CancellationToken cancellationToken)
|
|---|
| 19 | {
|
|---|
| 20 | var notification = new Domain.Entities.Notification
|
|---|
| 21 | {
|
|---|
| 22 | Content = request.Content,
|
|---|
| [e882b92] | 23 | ContentType = request.ContentType,
|
|---|
| [877c13c] | 24 | IsRead = false,
|
|---|
| [73b69b2] | 25 | Link = request.Link,
|
|---|
| [e882b92] | 26 | UserId = request.UserId,
|
|---|
| 27 | StoryId = request.StoryId,
|
|---|
| 28 | CreatedAt = DateTime.UtcNow,
|
|---|
| [877c13c] | 29 | };
|
|---|
| 30 |
|
|---|
| 31 | await _notificationRepository.AddAsync(notification, cancellationToken);
|
|---|
| 32 |
|
|---|
| 33 | return new AddResponse(notification.Id);
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.