Coursework_ComputerStore_Li.../ComputerStoreBusinessLogic/BusinessLogic/RequestComponentLogic.cs
2023-05-17 17:58:35 +04:00

39 lines
1.4 KiB
C#

using ComputerStoreContracts.BusinessLogicContracts;
using ComputerStoreContracts.SearchModels;
using ComputerStoreContracts.StorageContracts;
using ComputerStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerStoreBusinessLogic.BusinessLogic
{
public class RequestComponentLogic : IRequestComponentLogic
{
private readonly ILogger _logger;
private readonly IRequestComponentStorage _requestComponentStorage;
public RequestComponentLogic(ILogger<PCLogic> logger, IRequestComponentStorage requestComponentStorage)
{
_logger = logger;
_requestComponentStorage = requestComponentStorage;
}
public List<RequestComponentViewModel>? ReadList(RequestSearchModel model)
{
_logger.LogInformation("ReadList. PCID:{ PCID}. OrderID:{ OrderID}. ID:{ ID}", model?.PCID, model?.OrderID,model?.ID);
var list = model.ID == null ? _requestComponentStorage.GetFullList() : _requestComponentStorage.GetFilteredList(model);
if(list == null)
{
_logger.LogWarning("ReadList return null list");
return new();
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
}
}