diff --git a/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj b/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj
index 8454587..4b0949c 100644
--- a/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj
+++ b/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj
@@ -8,6 +8,7 @@
+
diff --git a/ConfectionaryListImplement/DataListSingleton.cs b/ConfectionaryListImplement/DataListSingleton.cs
index 951d63d..ff1f4d0 100644
--- a/ConfectionaryListImplement/DataListSingleton.cs
+++ b/ConfectionaryListImplement/DataListSingleton.cs
@@ -10,6 +10,7 @@ namespace ConfectioneryListImplement
public List Pastry { get; set; }
public List Clients { get; set; }
public List Implementers { get; set; }
+ public List Messages { get; set; }
private DataListSingleton()
{
@@ -18,6 +19,7 @@ namespace ConfectioneryListImplement
Pastry = new List();
Clients = new List();
Implementers = new List();
+ Messages = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/ConfectionaryListImplement/MessageInfo.cs b/ConfectionaryListImplement/MessageInfo.cs
new file mode 100644
index 0000000..73645a4
--- /dev/null
+++ b/ConfectionaryListImplement/MessageInfo.cs
@@ -0,0 +1,56 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.ViewModels;
+using ConfectioneryDataModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConfectioneryListImplement.Models
+{
+ // Update в этой сущности не нужен, поскольку в логике мы не изменяем никакие поля после создания письма
+ public class MessageInfo : IMessageInfoModel
+ {
+ public string MessageId { get; private set; } = string.Empty;
+
+ public int? ClientId { get; private set; }
+
+ public string SenderName { get; private set; } = string.Empty;
+
+ public DateTime DateDelivery { get; private set; } = DateTime.Now;
+
+ public string Subject { get; private set; } = string.Empty;
+
+ public string Body { get; private set; } = string.Empty;
+
+ 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,
+ };
+
+ }
+
+}
diff --git a/ConfectionaryListImplement/MessageInfoStorage.cs b/ConfectionaryListImplement/MessageInfoStorage.cs
new file mode 100644
index 0000000..0dc21ca
--- /dev/null
+++ b/ConfectionaryListImplement/MessageInfoStorage.cs
@@ -0,0 +1,61 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.SearchModels;
+using ConfectioneryContracts.StoragesContract;
+using ConfectioneryContracts.ViewModels;
+using ConfectioneryListImplement.Models;
+
+namespace ConfectioneryListImplement
+{
+ public class MessageInfoStorage : IMessageInfoStorage
+ {
+ private readonly DataListSingleton _source;
+ public MessageInfoStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
+ {
+ foreach (var message in _source.Messages)
+ {
+ if (model.MessageId != null && model.MessageId == message.MessageId)
+ return message.GetViewModel;
+ }
+ return null;
+ }
+
+ public List GetFilteredList(MessageInfoSearchModel model)
+ {
+ List result = new();
+ foreach (var item in _source.Messages)
+ {
+ if (item.ClientId.HasValue && item.ClientId == model.ClientId)
+ {
+ result.Add(item.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ List result = new();
+ foreach (var item in _source.Messages)
+ {
+ result.Add(item.GetViewModel);
+ }
+ return result;
+ }
+
+ public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
+ {
+ var newMessage = MessageInfo.Create(model);
+ if (newMessage == null)
+ {
+ return null;
+ }
+ _source.Messages.Add(newMessage);
+ return newMessage.GetViewModel;
+ }
+ }
+}