работает

This commit is contained in:
ityurner02@mail.ru 2023-04-17 18:03:03 +04:00
parent df2c68349c
commit 04daacfad4
3 changed files with 80 additions and 57 deletions

View File

@ -42,7 +42,6 @@ namespace PlumbingRepair
DataGridView.Columns["WorkId"].Visible = false; DataGridView.Columns["WorkId"].Visible = false;
DataGridView.Columns["ClientId"].Visible = false; DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["ImplementerId"].Visible = false; DataGridView.Columns["ImplementerId"].Visible = false;
DataGridView.Columns["DateImplement"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");

View File

@ -41,13 +41,9 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
return true; 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 }); CheckModel(model, false);
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
OrderViewModel? order = _orderStorage.GetElement(new OrderSearchModel OrderViewModel? order = _orderStorage.GetElement(new OrderSearchModel
{ {
@ -65,10 +61,36 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
if (model.Status + 1 != newStatus) if (model.Status + 1 != newStatus)
{ {
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Incorrect Order status.");
return false; return false;
} }
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.Status = newStatus;
model.DateCreate = viewModel.DateCreate; model.DateCreate = viewModel.DateCreate;
model.Sum = viewModel.Sum; model.Sum = viewModel.Sum;
@ -79,16 +101,18 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
{ {
model.ImplementerId = viewModel.ImplementerId; model.ImplementerId = viewModel.ImplementerId;
} }
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
if (model.Status == OrderStatus.Готов) else
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); {
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model);
if (_orderStorage.Update(model) == null) if (_orderStorage.Update(model) == null)
{ {
model.Status--;
_logger.LogWarning("Update operation failed"); _logger.LogWarning("Update operation failed");
return false; return false;
} }
return true; return true;
} }