работает
This commit is contained in:
parent
df2c68349c
commit
04daacfad4
@ -42,7 +42,6 @@ namespace PlumbingRepair
|
||||
DataGridView.Columns["WorkId"].Visible = false;
|
||||
DataGridView.Columns["ClientId"].Visible = false;
|
||||
DataGridView.Columns["ImplementerId"].Visible = false;
|
||||
DataGridView.Columns["DateImplement"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
|
@ -41,13 +41,9 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
/*public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
CheckModel(model, false);
|
||||
|
||||
OrderViewModel? order = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
@ -64,12 +60,38 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
if (!model.ImplementerId.HasValue) model.ImplementerId = order.ImplementerId;
|
||||
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Incorrect Order status.");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = newStatus;
|
||||
model.Status = newStatus;
|
||||
|
||||
if (newStatus == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (viewModel.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
model.DateCreate = viewModel.DateCreate;
|
||||
model.Sum = viewModel.Sum;
|
||||
model.Count = viewModel.Count;
|
||||
@ -79,20 +101,22 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
{
|
||||
model.ImplementerId = viewModel.ImplementerId;
|
||||
}
|
||||
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
@ -23,37 +23,37 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new PlumbingRepairDataBase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
using var context = new PlumbingRepairDataBase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
@ -75,16 +75,16 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new PlumbingRepairDataBase();
|
||||
using var context = new PlumbingRepairDataBase();
|
||||
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
return context.Orders
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status == x.Status) &&
|
||||
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
|
||||
|
Loading…
Reference in New Issue
Block a user