From e0320e7c9944a432ee6019dbac017b7d9e3ffaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B4=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Wed, 2 Aug 2023 15:10:00 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D0=B2?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Notifications/NotificationService.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/AsbCloudApp/Services/Notifications/NotificationService.cs b/AsbCloudApp/Services/Notifications/NotificationService.cs index 849a2833..270d90db 100644 --- a/AsbCloudApp/Services/Notifications/NotificationService.cs +++ b/AsbCloudApp/Services/Notifications/NotificationService.cs @@ -92,13 +92,10 @@ public class NotificationService cancellationToken) ?? throw new ArgumentInvalidException("Уведомление не найдено", nameof(idNotification)); - if (isRead) - { - if (notification.SentDate == null) - throw new ArgumentInvalidException("Уведомление не может быть прочитано", nameof(isRead)); - - notification.SentDate = DateTime.UtcNow; - } + if(isRead && !notification.SentDate.HasValue) + throw new ArgumentInvalidException("Уведомление не может быть прочитано", nameof(isRead)); + + notification.ReadDate = isRead ? DateTime.UtcNow : null; await notificationRepository.UpdateAsync(notification, cancellationToken);