Добавлена возможность обновить исполнителя для заказа
This commit is contained in:
parent
6457bc4afa
commit
fb5507c55c
@ -90,16 +90,17 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
}
|
||||
if ((int)vmodel.Status + 1 != (int)orderStatus)
|
||||
{
|
||||
throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " +
|
||||
throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " +
|
||||
$"Текущий статус: {vmodel.Status} \n" +
|
||||
$"Планируемый статус: {orderStatus} \n" +
|
||||
$"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}",
|
||||
nameof(vmodel));
|
||||
$"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}");
|
||||
}
|
||||
model.Status = orderStatus;
|
||||
model.DateCreate = vmodel.DateCreate;
|
||||
if (model.DateImplement == null)
|
||||
model.DateImplement = vmodel.DateImplement;
|
||||
if (vmodel.ImplementerId.HasValue)
|
||||
model.ImplementerId = vmodel.ImplementerId;
|
||||
model.PastryId = vmodel.PastryId;
|
||||
model.Sum = vmodel.Sum;
|
||||
model.Count= vmodel.Count;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||
using ConfectioneryContracts.SearchModels;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -34,7 +35,7 @@ namespace ConfectioneryBusinessLogic
|
||||
_logger.LogWarning("DoWork. Implementers is null");
|
||||
return;
|
||||
}
|
||||
var orders = _orderLogic.ReadList(new OrderSearchModel { /*Status = OrderStatus.Принят*/ });
|
||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
@ -71,7 +72,7 @@ namespace ConfectioneryBusinessLogic
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
// ImplementerId = implementer.Id
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||
@ -113,8 +114,8 @@ namespace ConfectioneryBusinessLogic
|
||||
{
|
||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
// ImplementerId = implementer.Id,
|
||||
// Status = OrderStatus.Выполняется
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Выполняется
|
||||
}));
|
||||
if (runOrder == null)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ namespace ConfectioneryFileImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ImplementerId = model.ImplementerId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Id = model.Id,
|
||||
};
|
||||
}
|
||||
@ -77,8 +77,9 @@ namespace ConfectioneryFileImplement.Models
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
ImplementerId = model.ImplementerId;
|
||||
DateImplement = model.DateImplement;
|
||||
Id = model.Id;
|
||||
Id = model.Id;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ namespace ConfectioneryListImplement.Models
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
Id = model.Id;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
|
@ -78,6 +78,7 @@ namespace ConfectioneryDatabaseImplement.Models
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
Id = model.Id;
|
||||
}
|
||||
public OrderViewModel GetViewModel
|
||||
|
@ -56,13 +56,17 @@ namespace ConfectioneryDatabaseImplement.Implements
|
||||
.Where(x => model.DateFrom <= x.DateCreate.Date &&
|
||||
x.DateCreate.Date <= model.DateTo);
|
||||
}
|
||||
else if (model.Status.HasValue && model.ImplementerId.HasValue)
|
||||
{
|
||||
queryWhere = context.Orders.Where(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status);
|
||||
}
|
||||
else if (model.Status.HasValue)
|
||||
{
|
||||
queryWhere = context.Orders.Where(x => x.Status == model.Status);
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
queryWhere = context.Orders.Where(x => x.Client.Id == model.ClientId);
|
||||
queryWhere = context.Orders.Where(x => x.ClientId == model.ClientId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user