edit orderlogic
This commit is contained in:
parent
54a20dda00
commit
1d8c53582b
@ -5,6 +5,7 @@ using PizzeriaContracts.SearchModels;
|
||||
using PizzeriaContracts.StorageContracts;
|
||||
using PizzeriaContracts.ViewModels;
|
||||
using PizzeriaDataModels.Enums;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PizzeriaBusinessLogic.BusinessLogic
|
||||
{
|
||||
@ -13,13 +14,29 @@ namespace PizzeriaBusinessLogic.BusinessLogic
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
static readonly object _locker = new object();
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||
model.ClientId, model.Status, model.ImplementerId, model.DateFrom, model.DateTo, model.Id);
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
|
||||
@ -42,7 +59,8 @@ namespace PizzeriaBusinessLogic.BusinessLogic
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. OrderId: {Id}.", model?.Id);
|
||||
_logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||
model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
@ -92,6 +110,15 @@ namespace PizzeriaBusinessLogic.BusinessLogic
|
||||
}
|
||||
model.Status = status;
|
||||
|
||||
if (order.ImplementerId.HasValue)
|
||||
{
|
||||
model.ImplementerId = order.ImplementerId;
|
||||
}
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
Loading…
Reference in New Issue
Block a user