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

View File

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