Compare commits

...

2 Commits

6 changed files with 21 additions and 15 deletions

View File

@ -102,7 +102,6 @@ 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,7 +59,6 @@ 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,
@ -67,7 +66,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Sum = viewModel.Sum Sum = viewModel.Sum
}; };
CheckModel(model); CheckModel(model, false);
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,7 +12,6 @@ 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,7 +11,6 @@ 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 order.GetViewModel; return GetViewModel(order);
} }
} }
return null; return null;
@ -47,7 +47,7 @@ namespace AutomobilePlantListImplements.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
result.Add(order.GetViewModel); result.Add(GetViewModel(order));
} }
} }
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(order.GetViewModel); result.Add(GetViewModel(order));
} }
return result; return result;
} }
@ -79,7 +79,7 @@ namespace AutomobilePlantListImplements.Implements
return null; return null;
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return newOrder.GetViewModel; return GetViewModel(newOrder);
} }
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 order.GetViewModel; return GetViewModel(order);
} }
} }
return null; return null;
@ -103,10 +103,24 @@ namespace AutomobilePlantListImplements.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return element.GetViewModel; return GetViewModel(element);
} }
} }
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,8 +14,6 @@ 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; }
@ -37,7 +35,6 @@ 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,
@ -60,7 +57,6 @@ 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,