using AbstractLawFirmContracts.BindingModels; using AbstractLawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.SearchModels; using AbstractLawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.ViewModels; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AbstractLawFirmBusinessLogic.BusinessLogic { public class MessageInfoLogic : IMessageInfoLogic { private readonly ILogger _logger; private readonly IMessageInfoStorage _messageStorage; public MessageInfoLogic(IMessageInfoStorage messageStorage, ILogger logger) { _messageStorage = messageStorage; _logger = logger; } public bool Create(MessageInfoBindingModel model) { if (_messageStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; } return true; } public List? ReadList(MessageInfoSearchModel? model) { _logger.LogInformation("ReadList. ClientID:{ClientID}. ID:{ ID}", model?.ClientId, model?.MessageId); var list = model == null ? _messageStorage.GetFullList() : _messageStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); return null; } _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } } }