diff --git a/AsbCloudApp/AsbCloudApp.csproj b/AsbCloudApp/AsbCloudApp.csproj
index 512a0c0a..79ec9867 100644
--- a/AsbCloudApp/AsbCloudApp.csproj
+++ b/AsbCloudApp/AsbCloudApp.csproj
@@ -18,8 +18,4 @@
-
-
-
-
diff --git a/AsbCloudApp/Data/NotificationDto.cs b/AsbCloudApp/Data/NotificationDto.cs
index d067a633..06fbc189 100644
--- a/AsbCloudApp/Data/NotificationDto.cs
+++ b/AsbCloudApp/Data/NotificationDto.cs
@@ -67,7 +67,21 @@ public class NotificationDto : IId
}
set
{
-
+ switch (value)
+ {
+ case 0:
+ SentDate = null;
+ ReadDate = null;
+ break;
+ case 1:
+ SentDate = DateTime.UtcNow;
+ ReadDate = null;
+ break;
+ case 2:
+ SentDate = DateTime.UtcNow;
+ ReadDate = DateTime.UtcNow;
+ break;
+ }
}
}
diff --git a/AsbCloudApp/Requests/NotifyRequest.cs b/AsbCloudApp/Requests/NotifyRequest.cs
index fc6df840..fdd4a1e5 100644
--- a/AsbCloudApp/Requests/NotifyRequest.cs
+++ b/AsbCloudApp/Requests/NotifyRequest.cs
@@ -36,6 +36,5 @@ public class NotifyRequest
/// Id типа доставки уведомления. Допустимое значение: 0, 1
///
[Required]
- [Range(minimum: 0, maximum: 1, ErrorMessage = "Id способа отправки уведомления недоступно. Допустимые: 0, 1")]
public int IdTransportType { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/Notifications/NotificationService.cs b/AsbCloudApp/Services/Notifications/NotificationService.cs
index b8916b15..901a5348 100644
--- a/AsbCloudApp/Services/Notifications/NotificationService.cs
+++ b/AsbCloudApp/Services/Notifications/NotificationService.cs
@@ -7,7 +7,6 @@ using AsbCloudApp.Data;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
-using AsbCloudDb.Model;
namespace AsbCloudApp.Services.Notifications;
@@ -96,11 +95,13 @@ public class NotificationService
///
public async Task RenotifyAsync(int idUser, CancellationToken cancellationToken)
{
+ const int idTransportType = 0;
+
var notifications = await notificationRepository.GetAllAsync(idUser, false,
- Notification.IdTransportTypeSignalR,
+ idTransportType,
cancellationToken);
- var notificationTransportService = GetTransportService(Notification.IdTransportTypeSignalR);
+ var notificationTransportService = GetTransportService(idTransportType);
await notificationTransportService.SendRangeAsync(notifications,
cancellationToken);
diff --git a/AsbCloudDb/Model/Notification.cs b/AsbCloudDb/Model/Notification.cs
index e363d3d2..09f718b1 100644
--- a/AsbCloudDb/Model/Notification.cs
+++ b/AsbCloudDb/Model/Notification.cs
@@ -8,9 +8,6 @@ namespace AsbCloudDb.Model;
[Table("t_notification"), Comment("Уведомления")]
public class Notification : IId
{
- public const int IdTransportTypeSignalR = 0;
- public const int IdTransportTypeTypeEmail = 1;
-
[Key]
[Column("id")]
public int Id { get; set; }
diff --git a/AsbCloudInfrastructure/Services/Email/EmailNotificationTransportService.cs b/AsbCloudInfrastructure/Services/Email/EmailNotificationTransportService.cs
index 4211c73e..e0f4ba0e 100644
--- a/AsbCloudInfrastructure/Services/Email/EmailNotificationTransportService.cs
+++ b/AsbCloudInfrastructure/Services/Email/EmailNotificationTransportService.cs
@@ -9,7 +9,6 @@ using AsbCloudApp.Data;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services.Notifications;
-using AsbCloudDb.Model;
using AsbCloudInfrastructure.Background;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -41,7 +40,7 @@ namespace AsbCloudInfrastructure.Services.Email
this.backgroundWorker = backgroundWorker;
}
- public int IdTransportType => Notification.IdTransportTypeTypeEmail;
+ public int IdTransportType => 1;
public Task SendAsync(NotificationDto notification, CancellationToken cancellationToken)
{
diff --git a/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs b/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs
index 5c1d1e50..1f6f4f67 100644
--- a/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs
+++ b/AsbCloudWebApi/SignalR/Services/NotificationPublisher.cs
@@ -4,7 +4,6 @@ using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
-using AsbCloudDb.Model;
using AsbCloudWebApi.SignalR.Messages;
using Microsoft.AspNetCore.SignalR;
@@ -27,6 +26,8 @@ public class NotificationPublisher
public async Task PublishAsync(IGrouping groupedNotifications, CancellationToken cancellationToken)
{
+ const int idTransportType = 0;
+
var connectionId = connectionManagerService.GetConnectionIdByUserId(groupedNotifications.Key);
if (!string.IsNullOrWhiteSpace(connectionId))
@@ -44,8 +45,8 @@ public class NotificationPublisher
await PublishMessageAsync(connectionId, new NotificationMessage
{
Notifications = notifications,
- CountUnread = await notificationRepository.GetUnreadCountAsync(groupedNotifications.Key,
- Notification.IdTransportTypeSignalR,
+ CountUnread = await notificationRepository.GetUnreadCountAsync(groupedNotifications.Key,
+ idTransportType,
cancellationToken)
}, cancellationToken);
}
diff --git a/AsbCloudWebApi/SignalR/Services/SignalRNotificationTransportService.cs b/AsbCloudWebApi/SignalR/Services/SignalRNotificationTransportService.cs
index 08258bef..b418c0b5 100644
--- a/AsbCloudWebApi/SignalR/Services/SignalRNotificationTransportService.cs
+++ b/AsbCloudWebApi/SignalR/Services/SignalRNotificationTransportService.cs
@@ -5,7 +5,6 @@ using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Services.Notifications;
-using AsbCloudDb.Model;
using AsbCloudInfrastructure.Background;
using Microsoft.Extensions.DependencyInjection;
@@ -20,7 +19,7 @@ public class SignalRNotificationTransportService : INotificationTransportService
this.backgroundWorker = backgroundWorker;
}
- public int IdTransportType => Notification.IdTransportTypeSignalR;
+ public int IdTransportType => 0;
public Task SendAsync(NotificationDto notification,
CancellationToken cancellationToken) => SendRangeAsync(new[] { notification }, cancellationToken);