Merge branch 'lab1_base' into lab2_base

This commit is contained in:
prodigygirl 2023-03-11 09:57:58 +04:00
commit a15b380638
6 changed files with 27 additions and 24 deletions

View File

@ -123,7 +123,7 @@
this.Controls.Add(this.labelCount); this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelFurniture); this.Controls.Add(this.labelFurniture);
this.Name = "FormCreateOrder"; this.Name = "FormCreateOrder";
this.Text = "FormCreateOrder"; this.Text = "Создание заказа";
this.Load += new System.EventHandler(this.FormCreateOrder_Load); this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -48,8 +48,7 @@ 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)
}); });

View File

@ -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;
} }

View File

@ -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.Неизвестен;

View File

@ -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;
}
} }
} }

View File

@ -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,
@ -55,12 +52,8 @@ namespace FurnitureAssemblyListImplement.Models
{ {
return; return;
} }
FurnitureId = model.FurnitureId;
FurnitureName = model.FurnitureName; Status = model.Status;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
@ -68,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,