2024-06-01 16:27:44 +04:00
|
|
|
|
using SushiBarContracts.BindingModels;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-06-01 17:37:58 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2024-06-01 16:27:44 +04:00
|
|
|
|
|
|
|
|
|
namespace SushiBarDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class MessageInfo : IMessageInfoModel
|
|
|
|
|
{
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
[Key]
|
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
|
|
|
public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
public int? ClientId { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual Client? Client { get; set; }
|
|
|
|
|
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string SenderName { get; set; } = string.Empty;
|
|
|
|
|
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateDelivery { get; set; }
|
|
|
|
|
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string Subject { get; set; } = string.Empty;
|
|
|
|
|
|
2024-06-01 17:37:58 +04:00
|
|
|
|
[DataMember]
|
2024-06-01 16:27:44 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string Body { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public static MessageInfo? 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,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MessageInfoViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
MessageId = MessageId,
|
|
|
|
|
ClientId = ClientId,
|
|
|
|
|
SenderName = SenderName,
|
|
|
|
|
DateDelivery = DateDelivery,
|
|
|
|
|
Subject = Subject,
|
|
|
|
|
Body = Body
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-06-01 17:37:58 +04:00
|
|
|
|
}
|