2024-05-14 11:30:42 +04:00
|
|
|
|
using FurnitureAssemblyContracts.BindingModels;
|
|
|
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
|
|
|
using FurnitureAssemblyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2024-05-14 11:30:42 +04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyFileImplement.Models
|
|
|
|
|
{
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataContract]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public class MessageInfo : IMessageInfoModel
|
|
|
|
|
{
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public string MessageId { get; private set; } = string.Empty;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public int? ClientId { get; private set; }
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public string SenderName { get; private set; } = string.Empty;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public string Subject { get; private set; } = string.Empty;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
[DataMember]
|
2024-05-14 11:30:42 +04:00
|
|
|
|
public string Body { get; private set; } = string.Empty;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
public int Id => throw new NotImplementedException();
|
2024-05-14 11:30:42 +04:00
|
|
|
|
|
|
|
|
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
MessageId = model.MessageId,
|
|
|
|
|
ClientId = model.ClientId,
|
|
|
|
|
Body = model.Body,
|
|
|
|
|
Subject = model.Subject,
|
|
|
|
|
SenderName = model.SenderName,
|
|
|
|
|
DateDelivery = model.DateDelivery,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MessageInfo? Create(XElement element)
|
|
|
|
|
{
|
|
|
|
|
if (element == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new MessageInfo()
|
|
|
|
|
{
|
|
|
|
|
MessageId = element.Element("MessageId")!.Value,
|
|
|
|
|
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
|
|
|
|
Body = element.Element("Body")!.Value,
|
|
|
|
|
Subject = element.Element("Subject")!.Value,
|
|
|
|
|
SenderName = element.Element("SenderName")!.Value,
|
|
|
|
|
DateDelivery = DateTime.ParseExact(element.Element("DateDelivery")!.Value, "G", null)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MessageInfoViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Body = Body,
|
|
|
|
|
Subject = Subject,
|
|
|
|
|
ClientId = ClientId,
|
|
|
|
|
MessageId = MessageId,
|
|
|
|
|
SenderName = SenderName,
|
|
|
|
|
DateDelivery = DateDelivery,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public XElement GetXElement => new("MessageInfo",
|
|
|
|
|
new XElement("SenderName", SenderName),
|
|
|
|
|
new XElement("ClientId", ClientId),
|
|
|
|
|
new XElement("DateDelivery", DateDelivery),
|
|
|
|
|
new XAttribute("MessageId", MessageId),
|
|
|
|
|
new XElement("Body", Body),
|
|
|
|
|
new XElement("Subject", Subject)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|