diff --git a/ConfectionaryFileImplement/MessageInfo.cs b/ConfectionaryFileImplement/MessageInfo.cs index 65396ae..ba0dc59 100644 --- a/ConfectionaryFileImplement/MessageInfo.cs +++ b/ConfectionaryFileImplement/MessageInfo.cs @@ -24,8 +24,10 @@ namespace ConfectioneryFileImplement.Models public string Subject { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty; + public bool HasRead { get; private set; } + public string? Reply { get; private set; } - public static MessageInfo? Create(MessageInfoBindingModel model) + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { @@ -34,6 +36,8 @@ namespace ConfectioneryFileImplement.Models return new() { Body = model.Body, + Reply = model.Reply, + HasRead = model.HasRead, Subject = model.Subject, ClientId = model.ClientId, MessageId = model.MessageId, @@ -51,6 +55,8 @@ namespace ConfectioneryFileImplement.Models return new() { Body = element.Attribute("Body")!.Value, + Reply = element.Attribute("Reply")!.Value, + HasRead = Convert.ToBoolean(element.Attribute("HasRead")!.Value), Subject = element.Attribute("Subject")!.Value, ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value), MessageId = element.Attribute("MessageId")!.Value, @@ -59,9 +65,21 @@ namespace ConfectioneryFileImplement.Models }; } - public MessageInfoViewModel GetViewModel => new() + public void Update(MessageInfoBindingModel model) + { + if (model == null) + { + return; + } + Reply = model.Reply; + HasRead = model.HasRead; + } + + public MessageInfoViewModel GetViewModel => new() { Body = Body, + Reply = Reply, + HasRead = HasRead, Subject = Subject, ClientId = ClientId, MessageId = MessageId, @@ -71,6 +89,8 @@ namespace ConfectioneryFileImplement.Models public XElement GetXElement => new("MessageInfo", new XAttribute("Body", Body), + new XAttribute("Reply", Reply), + new XAttribute("HasRead", HasRead), new XAttribute("Subject", Subject), new XAttribute("ClientId", ClientId), new XAttribute("MessageId", MessageId), diff --git a/ConfectionaryListImplement/MessageInfo.cs b/ConfectionaryListImplement/MessageInfo.cs index 73645a4..588b890 100644 --- a/ConfectionaryListImplement/MessageInfo.cs +++ b/ConfectionaryListImplement/MessageInfo.cs @@ -23,17 +23,21 @@ namespace ConfectioneryListImplement.Models public string Subject { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty; + public bool HasRead { get; private set; } + public string? Reply { get; private set; } - public static MessageInfo? Create(MessageInfoBindingModel model) + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { return null; } return new() - { - Body = model.Body, - Subject = model.Subject, + { + Body = model.Body, + Reply = model.Reply, + HasRead = model.HasRead, + Subject = model.Subject, ClientId = model.ClientId, MessageId = model.MessageId, SenderName = model.SenderName, @@ -41,9 +45,21 @@ namespace ConfectioneryListImplement.Models }; } + public void Update(MessageInfoBindingModel model) + { + if (model == null) + { + return; + } + Reply = model.Reply; + HasRead = model.HasRead; + } + public MessageInfoViewModel GetViewModel => new() { Body = Body, + Reply = Reply, + HasRead = HasRead, Subject = Subject, ClientId = ClientId, MessageId = MessageId, diff --git a/ConfectioneryContracts/BindingModels/MessageInfoBindingModel.cs b/ConfectioneryContracts/BindingModels/MessageInfoBindingModel.cs index 984939b..47b1fce 100644 --- a/ConfectioneryContracts/BindingModels/MessageInfoBindingModel.cs +++ b/ConfectioneryContracts/BindingModels/MessageInfoBindingModel.cs @@ -20,5 +20,8 @@ namespace ConfectioneryContracts.BindingModels public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } - } + + public bool HasRead { get; set; } + public string? Reply { get; set; } + } } diff --git a/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs b/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs index 5e38e72..43080c8 100644 --- a/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs +++ b/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs @@ -25,5 +25,8 @@ namespace ConfectioneryContracts.ViewModels [DisplayName("Текст")] public string Body { get; set; } = string.Empty; - } + + public bool HasRead { get; set; } + public string? Reply { get; set; } + } } diff --git a/ConfectioneryDataModels/IMessageInfoModel.cs b/ConfectioneryDataModels/IMessageInfoModel.cs index 38e68a1..8db6579 100644 --- a/ConfectioneryDataModels/IMessageInfoModel.cs +++ b/ConfectioneryDataModels/IMessageInfoModel.cs @@ -19,5 +19,9 @@ namespace ConfectioneryDataModels string Subject { get; } string Body { get; } - } + + public bool HasRead { get; } + + public string? Reply { get; } + } } diff --git a/ConfectioneryDatabaseImplement/MessageInfo.cs b/ConfectioneryDatabaseImplement/MessageInfo.cs index 988e037..4225660 100644 --- a/ConfectioneryDatabaseImplement/MessageInfo.cs +++ b/ConfectioneryDatabaseImplement/MessageInfo.cs @@ -23,7 +23,10 @@ namespace ConfectioneryDatabaseImplement.Models public Client? Client { get; private set; } - public static MessageInfo? Create(MessageInfoBindingModel model) + public bool HasRead { get; private set; } + public string? Reply { get; private set; } + + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { @@ -32,7 +35,9 @@ namespace ConfectioneryDatabaseImplement.Models return new() { Body = model.Body, - Subject = model.Subject, + Reply = model.Reply, + HasRead = model.HasRead, + Subject = model.Subject, ClientId = model.ClientId, MessageId = model.MessageId, SenderName = model.SenderName, @@ -40,10 +45,22 @@ namespace ConfectioneryDatabaseImplement.Models }; } - public MessageInfoViewModel GetViewModel => new() + public void Update(MessageInfoBindingModel model) + { + if (model == null) + { + return; + } + Reply = model.Reply; + HasRead = model.HasRead; + } + + public MessageInfoViewModel GetViewModel => new() { Body = Body, - Subject = Subject, + Reply = Reply, + HasRead = HasRead, + Subject = Subject, ClientId = ClientId, MessageId = MessageId, SenderName = SenderName,