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 var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
CarId = Convert.ToInt32(comboBoxCar.SelectedValue), CarId = Convert.ToInt32(comboBoxCar.SelectedValue),
CarName = comboBoxCar.Text,
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
}); });

View File

@ -59,6 +59,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
{ {
Id = viewModel.Id, Id = viewModel.Id,
CarId = viewModel.CarId, CarId = viewModel.CarId,
CarName = viewModel.CarName,
Status = viewModel.Status, Status = viewModel.Status,
DateCreate = viewModel.DateCreate, DateCreate = viewModel.DateCreate,
DateImplement = viewModel.DateImplement, DateImplement = viewModel.DateImplement,
@ -66,7 +67,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Sum = viewModel.Sum Sum = viewModel.Sum
}; };
CheckModel(model, false); CheckModel(model);
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. Order status incorrect.");

View File

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

View File

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

View File

@ -30,7 +30,7 @@ namespace AutomobilePlantListImplements.Implements
{ {
if (model.Id.HasValue && order.Id == model.Id) if (model.Id.HasValue && order.Id == model.Id)
{ {
return GetViewModel(order); return order.GetViewModel;
} }
} }
return null; return null;
@ -47,7 +47,7 @@ namespace AutomobilePlantListImplements.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
result.Add(GetViewModel(order)); result.Add(order.GetViewModel);
} }
} }
return result; return result;
@ -58,7 +58,7 @@ namespace AutomobilePlantListImplements.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(GetViewModel(order)); result.Add(order.GetViewModel);
} }
return result; return result;
} }
@ -79,7 +79,7 @@ namespace AutomobilePlantListImplements.Implements
return null; return null;
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return GetViewModel(newOrder); return newOrder.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -89,7 +89,7 @@ namespace AutomobilePlantListImplements.Implements
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
order.Update(model); order.Update(model);
return GetViewModel(order); return order.GetViewModel;
} }
} }
return null; return null;
@ -103,24 +103,10 @@ namespace AutomobilePlantListImplements.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return GetViewModel(element); return element.GetViewModel;
} }
} }
return null; 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 int CarId { get; private set; }
public string CarName { get; private set; } = string.Empty;
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -35,6 +37,7 @@ namespace AutomobilePlantListImplements.Models
return new Order return new Order
{ {
CarId = model.CarId, CarId = model.CarId,
CarName = model.CarName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -57,6 +60,7 @@ namespace AutomobilePlantListImplements.Models
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
CarId = CarId, CarId = CarId,
CarName = CarName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
DateCreate = DateCreate, DateCreate = DateCreate,