Добавлены два поля сообщения

This commit is contained in:
Данияр Аглиуллов 2023-03-18 01:42:57 +04:00
parent 5c58ac9317
commit 9f71199535
6 changed files with 76 additions and 13 deletions

View File

@ -24,6 +24,8 @@ namespace ConfectioneryFileImplement.Models
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
public string Body { 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)
{ {
@ -34,6 +36,8 @@ namespace ConfectioneryFileImplement.Models
return new() return new()
{ {
Body = model.Body, Body = model.Body,
Reply = model.Reply,
HasRead = model.HasRead,
Subject = model.Subject, Subject = model.Subject,
ClientId = model.ClientId, ClientId = model.ClientId,
MessageId = model.MessageId, MessageId = model.MessageId,
@ -51,6 +55,8 @@ namespace ConfectioneryFileImplement.Models
return new() return new()
{ {
Body = element.Attribute("Body")!.Value, Body = element.Attribute("Body")!.Value,
Reply = element.Attribute("Reply")!.Value,
HasRead = Convert.ToBoolean(element.Attribute("HasRead")!.Value),
Subject = element.Attribute("Subject")!.Value, Subject = element.Attribute("Subject")!.Value,
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value), ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
MessageId = element.Attribute("MessageId")!.Value, MessageId = element.Attribute("MessageId")!.Value,
@ -59,9 +65,21 @@ namespace ConfectioneryFileImplement.Models
}; };
} }
public void Update(MessageInfoBindingModel model)
{
if (model == null)
{
return;
}
Reply = model.Reply;
HasRead = model.HasRead;
}
public MessageInfoViewModel GetViewModel => new() public MessageInfoViewModel GetViewModel => new()
{ {
Body = Body, Body = Body,
Reply = Reply,
HasRead = HasRead,
Subject = Subject, Subject = Subject,
ClientId = ClientId, ClientId = ClientId,
MessageId = MessageId, MessageId = MessageId,
@ -71,6 +89,8 @@ namespace ConfectioneryFileImplement.Models
public XElement GetXElement => new("MessageInfo", public XElement GetXElement => new("MessageInfo",
new XAttribute("Body", Body), new XAttribute("Body", Body),
new XAttribute("Reply", Reply),
new XAttribute("HasRead", HasRead),
new XAttribute("Subject", Subject), new XAttribute("Subject", Subject),
new XAttribute("ClientId", ClientId), new XAttribute("ClientId", ClientId),
new XAttribute("MessageId", MessageId), new XAttribute("MessageId", MessageId),

View File

@ -23,6 +23,8 @@ namespace ConfectioneryListImplement.Models
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
public string Body { 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)
{ {
@ -33,6 +35,8 @@ namespace ConfectioneryListImplement.Models
return new() return new()
{ {
Body = model.Body, Body = model.Body,
Reply = model.Reply,
HasRead = model.HasRead,
Subject = model.Subject, Subject = model.Subject,
ClientId = model.ClientId, ClientId = model.ClientId,
MessageId = model.MessageId, MessageId = model.MessageId,
@ -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() public MessageInfoViewModel GetViewModel => new()
{ {
Body = Body, Body = Body,
Reply = Reply,
HasRead = HasRead,
Subject = Subject, Subject = Subject,
ClientId = ClientId, ClientId = ClientId,
MessageId = MessageId, MessageId = MessageId,

View File

@ -20,5 +20,8 @@ namespace ConfectioneryContracts.BindingModels
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
public bool HasRead { get; set; }
public string? Reply { get; set; }
} }
} }

View File

@ -25,5 +25,8 @@ namespace ConfectioneryContracts.ViewModels
[DisplayName("Текст")] [DisplayName("Текст")]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
public bool HasRead { get; set; }
public string? Reply { get; set; }
} }
} }

View File

@ -19,5 +19,9 @@ namespace ConfectioneryDataModels
string Subject { get; } string Subject { get; }
string Body { get; } string Body { get; }
public bool HasRead { get; }
public string? Reply { get; }
} }
} }

View File

@ -23,6 +23,9 @@ namespace ConfectioneryDatabaseImplement.Models
public Client? Client { get; private set; } public Client? Client { get; private set; }
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) if (model == null)
@ -32,6 +35,8 @@ namespace ConfectioneryDatabaseImplement.Models
return new() return new()
{ {
Body = model.Body, Body = model.Body,
Reply = model.Reply,
HasRead = model.HasRead,
Subject = model.Subject, Subject = model.Subject,
ClientId = model.ClientId, ClientId = model.ClientId,
MessageId = model.MessageId, MessageId = model.MessageId,
@ -40,9 +45,21 @@ namespace ConfectioneryDatabaseImplement.Models
}; };
} }
public void Update(MessageInfoBindingModel model)
{
if (model == null)
{
return;
}
Reply = model.Reply;
HasRead = model.HasRead;
}
public MessageInfoViewModel GetViewModel => new() public MessageInfoViewModel GetViewModel => new()
{ {
Body = Body, Body = Body,
Reply = Reply,
HasRead = HasRead,
Subject = Subject, Subject = Subject,
ClientId = ClientId, ClientId = ClientId,
MessageId = MessageId, MessageId = MessageId,