ISEbd-21.Gordeev.I.V.SushiB.../SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs

60 lines
1.8 KiB
C#
Raw Normal View History

2024-05-16 18:55:15 +04:00
using PrecastConcretePlantDataModels.Models;
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
2024-05-16 18:55:15 +04:00
namespace SushiBarDatabaseImplement.Models
{
[DataContract]
2024-05-16 18:55:15 +04:00
public class MessageInfo : IMessageInfoModel
{
[Key]
[DataMember]
2024-05-16 18:55:15 +04:00
public string MessageId { get; private set; } = string.Empty;
[DataMember]
2024-05-16 20:41:43 +04:00
public int? ClientId { get; private set; }
[DataMember]
2024-05-16 18:55:15 +04:00
public string SenderName { get; private set; } = string.Empty;
[DataMember]
2024-05-16 18:55:15 +04:00
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
2024-05-16 18:55:15 +04:00
public string Subject { get; private set; } = string.Empty;
[DataMember]
2024-05-16 18:55:15 +04:00
public string Body { get; private set; } = string.Empty;
[NotMapped]
public int Id { get; private set; }
2024-05-16 18:55:15 +04:00
public Client? Client { get; private set; }
public static MessageInfo? Create(MessageInfoBindingModel model)
{
if (model == null)
{
return null;
}
return new()
{
Body = model.Body,
Subject = model.Subject,
ClientId = model.ClientId,
MessageId = model.MessageId,
SenderName = model.SenderName,
DateDelivery = model.DateDelivery,
};
}
public MessageInfoViewModel GetViewModel => new()
{
Body = Body,
Subject = Subject,
ClientId = ClientId,
MessageId = MessageId,
SenderName = SenderName,
DateDelivery = DateDelivery,
};
}
}