Compare commits

..

No commits in common. "886ba20f878056691175c2b4a043c196495a13a5" and "678588e464cddeca1389464b628b3f657dd00eeb" have entirely different histories.

6 changed files with 15 additions and 21 deletions

View File

@ -102,6 +102,7 @@ namespace AutomobilePlant
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
CarId = Convert.ToInt32(comboBoxCar.SelectedValue),
CarName = comboBoxCar.Text,
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});

View File

@ -59,6 +59,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
{
Id = viewModel.Id,
CarId = viewModel.CarId,
CarName = viewModel.CarName,
Status = viewModel.Status,
DateCreate = viewModel.DateCreate,
DateImplement = viewModel.DateImplement,
@ -66,7 +67,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Sum = viewModel.Sum
};
CheckModel(model, false);
CheckModel(model);
if (model.Status + 1 != newStatus)
{
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");

View File

@ -12,6 +12,7 @@ namespace AutomobilePlantContracts.BindingModels
{
public int Id { get; set; }
public int CarId { get; set; }
public string CarName { get; set; } = string.Empty;
public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -11,6 +11,7 @@ namespace AutomobilePlantDataModels.Models
public interface IOrderModel : IId
{
int CarId { get; }
string CarName { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }

View File

@ -30,7 +30,7 @@ namespace AutomobilePlantListImplements.Implements
{
if (model.Id.HasValue && order.Id == model.Id)
{
return GetViewModel(order);
return order.GetViewModel;
}
}
return null;
@ -47,7 +47,7 @@ namespace AutomobilePlantListImplements.Implements
{
if (order.Id == model.Id)
{
result.Add(GetViewModel(order));
result.Add(order.GetViewModel);
}
}
return result;
@ -58,7 +58,7 @@ namespace AutomobilePlantListImplements.Implements
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(GetViewModel(order));
result.Add(order.GetViewModel);
}
return result;
}
@ -79,7 +79,7 @@ namespace AutomobilePlantListImplements.Implements
return null;
}
_source.Orders.Add(newOrder);
return GetViewModel(newOrder);
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
@ -89,7 +89,7 @@ namespace AutomobilePlantListImplements.Implements
if (order.Id == model.Id)
{
order.Update(model);
return GetViewModel(order);
return order.GetViewModel;
}
}
return null;
@ -103,24 +103,10 @@ namespace AutomobilePlantListImplements.Implements
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
return GetViewModel(element);
return element.GetViewModel;
}
}
return null;
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var car in _source.Cars)
{
if (car.Id == order.CarId)
{
viewModel.CarName = car.CarName;
break;
}
}
return viewModel;
}
}
}

View File

@ -14,6 +14,8 @@ namespace AutomobilePlantListImplements.Models
{
public int CarId { get; private set; }
public string CarName { get; private set; } = string.Empty;
public int Count { get; private set; }
public double Sum { get; private set; }
@ -35,6 +37,7 @@ namespace AutomobilePlantListImplements.Models
return new Order
{
CarId = model.CarId,
CarName = model.CarName,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -57,6 +60,7 @@ namespace AutomobilePlantListImplements.Models
public OrderViewModel GetViewModel => new()
{
CarId = CarId,
CarName = CarName,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,