From 341dcd033b72aca6b180696af82b7bf5e0eb67ee Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Tue, 18 Apr 2023 18:58:12 +0400 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B8=D0=B7=D0=BD=D0=B5=D1=81-=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=BF=D0=BE=20MessageInfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageInfoLogic.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/MessageInfoLogic.cs diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MessageInfoLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MessageInfoLogic.cs new file mode 100644 index 0000000..1425e6c --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MessageInfoLogic.cs @@ -0,0 +1,44 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace FurnitureAssemblyBusinessLogic +{ + public class MessageInfoLogic : IMessageInfoLogic + { + private readonly ILogger _logger; + private readonly IMessageInfoStorage _messageInfoStorage; + + public MessageInfoLogic(ILogger logger, IMessageInfoStorage messageInfoStorage) + { + _logger = logger; + _messageInfoStorage = messageInfoStorage; + } + + public bool Create(MessageInfoBindingModel model) + { + if (_messageInfoStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public List? ReadList(MessageInfoSearchModel? model) + { + _logger.LogInformation("ReadList. ClientId:{ClientId}. MessageId:{ MessageId}", model?.ClientId, model?.MessageId); + var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + } +}