2023-07-07 16:26:16 +05:00
|
|
|
|
using System;
|
2023-09-29 12:06:46 +05:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-07-07 16:26:16 +05:00
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Data;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-11 18:57:25 +05:00
|
|
|
|
/// DTO уведомления
|
2023-07-07 16:26:16 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
public class NotificationDto : IId
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Id уведомления
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Id получателя уведомления
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int IdUser { get; set; }
|
2023-07-25 13:36:09 +05:00
|
|
|
|
|
2023-07-07 16:26:16 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Id категории уведомления
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int IdNotificationCategory { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Заголовок уведомления
|
|
|
|
|
/// </summary>
|
2023-09-29 12:06:46 +05:00
|
|
|
|
[Required, StringLength(300, MinimumLength = 1, ErrorMessage = "Заголовок должен мыть не меньше 1-го знака и не больше 300")]
|
2023-07-07 16:26:16 +05:00
|
|
|
|
public string Title { get; set; } = null!;
|
|
|
|
|
|
2023-09-29 12:06:46 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сообщение уведомления
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Required, StringLength(2048, MinimumLength = 1, ErrorMessage = "Заголовок должен мыть не меньше 1-го знака и не больше 2048")]
|
|
|
|
|
public string Message { get; set; } = null!;
|
2023-07-13 14:44:40 +05:00
|
|
|
|
|
2023-07-25 13:36:09 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Дата регистрации уведомления
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime RegistrationDate { get; set; }
|
|
|
|
|
|
2023-07-07 16:26:16 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Дата отправки уведомления
|
|
|
|
|
/// </summary>
|
2023-07-11 18:57:25 +05:00
|
|
|
|
public DateTime? SentDate { get; set; }
|
|
|
|
|
|
2023-07-10 16:43:58 +05:00
|
|
|
|
/// <summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
/// Дата прочтения уведомления
|
2023-07-10 16:43:58 +05:00
|
|
|
|
/// </summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
public DateTime? ReadDate { get; set; }
|
2023-08-02 15:41:12 +05:00
|
|
|
|
|
2023-07-07 16:26:16 +05:00
|
|
|
|
/// <summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
/// Состояние уведомления
|
|
|
|
|
/// 0 - Зарегистрировано,
|
|
|
|
|
/// 1 - Отправлено,
|
|
|
|
|
/// 2 - Прочитано
|
2023-07-07 16:26:16 +05:00
|
|
|
|
/// </summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
public int IdState
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (SentDate is not null && ReadDate is not null)
|
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
|
|
if (SentDate is not null)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2023-08-02 15:41:12 +05:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-14 17:17:35 +05:00
|
|
|
|
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;
|
|
|
|
|
}
|
2023-08-02 15:41:12 +05:00
|
|
|
|
}
|
2023-07-13 14:44:40 +05:00
|
|
|
|
}
|
2023-07-11 18:57:25 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
/// Id типа доставки уведомления
|
|
|
|
|
/// 0 - SignalR
|
2023-07-19 14:24:22 +05:00
|
|
|
|
/// 1 - Email
|
2023-07-11 18:57:25 +05:00
|
|
|
|
/// </summary>
|
2023-09-29 12:06:46 +05:00
|
|
|
|
[Range(0,1)]
|
2023-07-13 14:44:40 +05:00
|
|
|
|
public int IdTransportType { get; set; }
|
|
|
|
|
|
2023-07-11 18:57:25 +05:00
|
|
|
|
/// <summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
/// DTO категории уведомления
|
2023-07-11 18:57:25 +05:00
|
|
|
|
/// </summary>
|
2023-07-13 14:44:40 +05:00
|
|
|
|
public NotificationCategoryDto NotificationCategory { get; set; } = null!;
|
2023-07-07 16:26:16 +05:00
|
|
|
|
}
|