Исправление: вычисляемое поле теперь реально вычисляемое
This commit is contained in:
parent
2a0061014a
commit
f43443cb14
@ -49,7 +49,6 @@ namespace FurnitureAssembly
|
|||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
||||||
FurnitureName = comboBoxProduct.Text,
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
@ -139,11 +139,11 @@ namespace FurnitureAssemblyBusinessLogic
|
|||||||
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum));
|
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Order. OrderId: { Id}. OrderStatus: {OrderStatus} DateCreate: {DateCreate} " +
|
_logger.LogInformation("Order. OrderId: { Id}. OrderStatus: {OrderStatus} DateCreate: {DateCreate} " +
|
||||||
"FurnitureId:{FurnitureId}. FurnitureName:{FurnitureName}. Count:{ Count}. Sum:{ Sum}. ",
|
"FurnitureId:{FurnitureId}. Count:{ Count}. Sum:{ Sum}. ",
|
||||||
model.Id, model.Status, model.DateCreate, model.FurnitureId, model.FurnitureName, model.Count, model.Sum);
|
model.Id, model.Status, model.DateCreate, model.FurnitureId, model.Count, model.Sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderBindingModel Find(OrderBindingModel model)
|
private OrderBindingModel? Find(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
var modelView = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var modelView = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (modelView == null)
|
if (modelView == null)
|
||||||
@ -155,7 +155,6 @@ namespace FurnitureAssemblyBusinessLogic
|
|||||||
model.Count = modelView.Count;
|
model.Count = modelView.Count;
|
||||||
model.Sum = modelView.Sum;
|
model.Sum = modelView.Sum;
|
||||||
model.FurnitureId = model.FurnitureId;
|
model.FurnitureId = model.FurnitureId;
|
||||||
model.FurnitureName = modelView.FurnitureName;
|
|
||||||
model.Status = modelView.Status;
|
model.Status = modelView.Status;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ namespace FurnitureAssemblyContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int FurnitureId { get; set; }
|
public int FurnitureId { get; set; }
|
||||||
public string FurnitureName { 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.Неизвестен;
|
||||||
|
@ -26,7 +26,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
{
|
{
|
||||||
var element = _source.Orders[i];
|
var element = _source.Orders[i];
|
||||||
_source.Orders.RemoveAt(i);
|
_source.Orders.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return GetOrderViewModel(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -43,7 +43,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (model.Id.HasValue && order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return order.GetViewModel;
|
return GetOrderViewModel(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (order.Id.Equals(model.Id))
|
if (order.Id.Equals(model.Id))
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(GetOrderViewModel(order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -68,7 +68,7 @@ namespace FurnitureAssemblyListImplement.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(GetOrderViewModel(order));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Orders.Add(newOrder);
|
_source.Orders.Add(newOrder);
|
||||||
return newOrder.GetViewModel;
|
return GetOrderViewModel(newOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -99,10 +99,24 @@ namespace FurnitureAssemblyListImplement.Implements
|
|||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
return order.GetViewModel;
|
return GetOrderViewModel(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OrderViewModel GetOrderViewModel(Order order)
|
||||||
|
{
|
||||||
|
OrderViewModel orderViewModel = order.GetViewModel;
|
||||||
|
|
||||||
|
foreach (var furniture in _source.Furnitures)
|
||||||
|
{
|
||||||
|
if (furniture.Id == order.Id)
|
||||||
|
{
|
||||||
|
orderViewModel.FurnitureName = furniture.FurnitureName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return orderViewModel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
{
|
{
|
||||||
public int FurnitureId { get; private set; }
|
public int FurnitureId { get; private set; }
|
||||||
|
|
||||||
public string FurnitureName { 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; }
|
||||||
@ -40,7 +38,6 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FurnitureId = model.FurnitureId,
|
FurnitureId = model.FurnitureId,
|
||||||
FurnitureName = model.FurnitureName,
|
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -64,7 +61,6 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
FurnitureName = FurnitureName,
|
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
|
Loading…
Reference in New Issue
Block a user