47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
|
using Microsoft.Extensions.Logging;
|
|||
|
using SewingDressesContracts.BindingModels;
|
|||
|
using SewingDressesContracts.BusinessLogicsContracts;
|
|||
|
using SewingDressesContracts.SearchModels;
|
|||
|
using SewingDressesContracts.StoragesContracts;
|
|||
|
using SewingDressesContracts.ViewModels;
|
|||
|
|
|||
|
namespace SewingDressesBusinessLogic.BusinessLogic
|
|||
|
{
|
|||
|
public class MessageInfoLogic : IMessageInfoLogic
|
|||
|
{
|
|||
|
private readonly ILogger _logger;
|
|||
|
|
|||
|
private readonly IMessageInfoStorage _messageStorage;
|
|||
|
|
|||
|
public MessageInfoLogic(IMessageInfoStorage messageStorage, ILogger<MessageInfoLogic> 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<MessageInfoViewModel>? 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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|