forked from ddrilling/AsbCloudServer
Правка типов дат с DateTime на DateTimeOffset в Notification и NotificationDto
This commit is contained in:
parent
0df79ee0fc
commit
ec2abd224e
@ -42,17 +42,17 @@ public class NotificationDto : IId
|
||||
/// Дата регистрации уведомления
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
public DateTimeOffset RegistrationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата отправки уведомления
|
||||
/// </summary>
|
||||
public DateTime? SentDate { get; set; }
|
||||
public DateTimeOffset? SentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата прочтения уведомления
|
||||
/// </summary>
|
||||
public DateTime? ReadDate { get; set; }
|
||||
public DateTimeOffset? ReadDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Состояние уведомления
|
||||
@ -82,12 +82,12 @@ public class NotificationDto : IId
|
||||
ReadDate = null;
|
||||
break;
|
||||
case 1:
|
||||
SentDate = DateTime.UtcNow;
|
||||
SentDate = DateTimeOffset.UtcNow;
|
||||
ReadDate = null;
|
||||
break;
|
||||
case 2:
|
||||
SentDate = DateTime.UtcNow;
|
||||
ReadDate = DateTime.UtcNow;
|
||||
SentDate = DateTimeOffset.UtcNow;
|
||||
ReadDate = DateTimeOffset.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ public class NotificationDeleteRequest
|
||||
/// <summary>
|
||||
/// Меньше или равно дате отправки
|
||||
/// </summary>
|
||||
public DateTime? LtSentDate { get; set; }
|
||||
public DateTimeOffset? LtSentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате прочтения
|
||||
/// </summary>
|
||||
public DateTime? LtReadDate { get; set; }
|
||||
public DateTimeOffset? LtReadDate { get; set; }
|
||||
}
|
@ -49,7 +49,7 @@ public class NotificationService
|
||||
var notification = new NotificationDto
|
||||
{
|
||||
IdUser = request.IdUser,
|
||||
RegistrationDate = DateTime.UtcNow,
|
||||
RegistrationDate = DateTimeOffset.UtcNow,
|
||||
IdNotificationCategory = notificationCategory.Id,
|
||||
Title = request.Title,
|
||||
Message = request.Message,
|
||||
@ -71,7 +71,7 @@ public class NotificationService
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
await notificationRepository.UpdateAsync(notification, cancellationToken);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class NotificationService
|
||||
if(isRead && !notification.SentDate.HasValue)
|
||||
throw new ArgumentInvalidException(nameof(isRead), "Уведомление не может быть прочитано");
|
||||
|
||||
notification.ReadDate = isRead ? DateTime.UtcNow : null;
|
||||
notification.ReadDate = isRead ? DateTimeOffset.UtcNow : null;
|
||||
|
||||
await notificationRepository.UpdateAsync(notification,
|
||||
cancellationToken);
|
||||
@ -119,7 +119,7 @@ public class NotificationService
|
||||
|
||||
var tasks = notifications.Select(notification =>
|
||||
{
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
return notificationRepository.UpdateAsync(notification, cancellationToken);
|
||||
});
|
||||
|
||||
|
@ -1581,17 +1581,17 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("message")
|
||||
.HasComment("Сообщение уведомления");
|
||||
|
||||
b.Property<DateTime?>("ReadDate")
|
||||
b.Property<DateTimeOffset?>("ReadDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("read_date")
|
||||
.HasComment("Дата прочтения уведомления");
|
||||
|
||||
b.Property<DateTime>("RegistrationDate")
|
||||
b.Property<DateTimeOffset>("RegistrationDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("registration_date")
|
||||
.HasComment("Дата регистрации уведомления");
|
||||
|
||||
b.Property<DateTime?>("SentDate")
|
||||
b.Property<DateTimeOffset?>("SentDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("sent_date")
|
||||
.HasComment("Дата отправки уведомления");
|
||||
|
@ -25,13 +25,13 @@ public class Notification : IId
|
||||
public string Message { get; set; } = null!;
|
||||
|
||||
[Column("registration_date"), Comment("Дата регистрации уведомления")]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
public DateTimeOffset RegistrationDate { get; set; }
|
||||
|
||||
[Column("sent_date"), Comment("Дата отправки уведомления")]
|
||||
public DateTime? SentDate { get; set; }
|
||||
public DateTimeOffset? SentDate { get; set; }
|
||||
|
||||
[Column("read_date"), Comment("Дата прочтения уведомления")]
|
||||
public DateTime? ReadDate { get; set; }
|
||||
public DateTimeOffset? ReadDate { get; set; }
|
||||
|
||||
[Column("id_transport_type"), Comment("Id типа доставки уведомления")]
|
||||
public int IdTransportType { get; set; }
|
||||
|
@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Background
|
||||
|
||||
await notificationService.SendAsync(notification, token);
|
||||
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
await notificationRepository.UpdateAsync(notification, token);
|
||||
|
||||
}
|
||||
|
@ -110,10 +110,10 @@ public class NotificationRepository : CrudRepositoryBase<NotificationDto, Notifi
|
||||
query = query.Where(n => n.IdNotificationCategory == request.IdCategory.Value);
|
||||
|
||||
if (request.LtSentDate.HasValue)
|
||||
query = query.Where(n => n.SentDate <= request.LtSentDate.Value);
|
||||
query = query.Where(n => n.SentDate <= request.LtSentDate.Value.ToUniversalTime());
|
||||
|
||||
if (request.LtReadDate.HasValue)
|
||||
query = query.Where(n => n.ReadDate <= request.LtReadDate.Value);
|
||||
query = query.Where(n => n.ReadDate <= request.LtReadDate.Value.ToUniversalTime());
|
||||
|
||||
dbContext.Notifications.RemoveRange(query);
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace AsbCloudWebApi.Tests.Services.Notification
|
||||
IdUser = 1,
|
||||
IdTransportType = 1,
|
||||
IdState = 0,
|
||||
RegistrationDate = DateTime.Now,
|
||||
RegistrationDate = DateTimeOffset.Now,
|
||||
IdNotificationCategory = 10000,
|
||||
};
|
||||
private readonly UserExtendedDto user = new UserExtendedDto()
|
||||
|
@ -35,7 +35,7 @@ public class NotificationPublisher
|
||||
{
|
||||
foreach (var notification in groupedNotifications)
|
||||
{
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
var notifications = groupedNotifications.Select(n => n);
|
||||
|
Loading…
Reference in New Issue
Block a user