2024-05-06 12:46:59 +04:00
|
|
|
|
using FoodOrdersContracts.BindingModels;
|
|
|
|
|
using FoodOrdersContracts.ViewModels;
|
|
|
|
|
using FoodOrdersDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-05-20 11:41:37 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Runtime.Serialization;
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
|
|
|
|
namespace FoodOrdersDatabaseImplement.Models
|
|
|
|
|
{
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataContract]
|
2024-05-06 12:46:59 +04:00
|
|
|
|
public class MessageInfo : IMessageInfoModel
|
|
|
|
|
{
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
[DataMember]
|
2024-05-06 12:46:59 +04:00
|
|
|
|
[Key]
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
|
|
|
public string MessageId { get; set; } = string.Empty;
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public int? ClientId { get; set; }
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
[Required]
|
|
|
|
|
public string SenderName { get; set; } = string.Empty;
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateDelivery { get; set; }
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
[Required]
|
|
|
|
|
public string Subject { get; set; } = string.Empty;
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
2024-05-20 11:41:37 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
[Required]
|
|
|
|
|
public string Body { get; set; } = string.Empty;
|
2024-05-06 12:46:59 +04:00
|
|
|
|
|
|
|
|
|
public virtual 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,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|