PIbd-21_MasenkinMS_Aircraft.../AircraftPlant/AircraftPlantListImplement/Models/Message.cs

113 lines
2.6 KiB
C#
Raw Normal View History

2024-05-04 22:30:27 +04:00
using AircraftPlantContracts.BindingModels;
using AircraftPlantContracts.ViewModels;
using AircraftPlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AircraftPlantListImplement.Models
{
/// <summary>
/// Сущность "Письмо"
/// </summary>
public class Message : IMessageInfoModel
{
/// <summary>
/// Идентификатор
/// </summary>
public string MessageId { get; set; } = string.Empty;
/// <summary>
/// Идентификатор клиента
/// </summary>
public int? ClientId { get; set; }
/// <summary>
/// Адрес электронной почты отправителя
/// </summary>
public string SenderName { get; set; } = string.Empty;
/// <summary>
/// Дата получения письма
/// </summary>
public DateTime DateDelivery { get; set; }
/// <summary>
/// Заголовок письма
/// </summary>
public string Subject { get; set; } = string.Empty;
/// <summary>
/// Тело письма
/// </summary>
public string Body { get; set; } = string.Empty;
2024-05-06 03:07:09 +04:00
/// <summary>
/// Письмо прочитано
/// </summary>
public bool IsChecked { get; set; }
/// <summary>
/// Ответ на писмо
/// </summary>
public string? Reply { get; set; }
2024-05-04 22:30:27 +04:00
/// <summary>
/// Создание модели письма
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static Message? Create(MessageInfoBindingModel model)
{
if (model == null)
{
return null;
}
return new()
{
MessageId = model.MessageId,
ClientId = model.ClientId,
SenderName = model.SenderName,
DateDelivery = model.DateDelivery,
Subject = model.Subject,
Body = model.Body,
2024-05-06 03:07:09 +04:00
IsChecked = model.IsChecked,
Reply = model.Reply
2024-05-04 22:30:27 +04:00
};
}
/// <summary>
2024-05-06 03:07:09 +04:00
/// Изменение модели письма
2024-05-04 22:30:27 +04:00
/// </summary>
2024-05-06 03:07:09 +04:00
/// <param name="model"></param>
public void Update(MessageInfoBindingModel model)
{
if (model == null)
{
return;
}
IsChecked = model.IsChecked;
Reply = model.Reply;
}
/// <summary>
/// Получение модели письма
/// </summary>
public MessageInfoViewModel GetViewModel => new()
2024-05-04 22:30:27 +04:00
{
MessageId = MessageId,
ClientId = ClientId,
SenderName = SenderName,
DateDelivery = DateDelivery,
Subject = Subject,
2024-05-06 03:07:09 +04:00
Body = Body,
IsChecked = IsChecked,
Reply = Reply
2024-05-04 22:30:27 +04:00
};
}
}