2024-05-14 11:30:42 +04:00
|
|
|
|
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;
|
|
|
|
|
|
2024-05-14 11:56:24 +04:00
|
|
|
|
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage)
|
2024-05-14 11:30:42 +04:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_messageInfoStorage = messageInfoStorage;
|
2024-05-14 11:56:24 +04:00
|
|
|
|
}
|
2024-05-14 11:30:42 +04:00
|
|
|
|
|
|
|
|
|
public bool Create(MessageInfoBindingModel model)
|
2024-05-14 11:56:24 +04:00
|
|
|
|
{
|
2024-05-14 11:30:42 +04:00
|
|
|
|
if (_messageInfoStorage.Insert(model) == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("Insert operation failed");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<MessageInfoViewModel>? 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|