Merge branch 'lab1_base' into lab1_hard

This commit is contained in:
prodigygirl 2023-03-12 11:37:12 +04:00
commit bfd4563ac9
6 changed files with 27 additions and 24 deletions

View File

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

View File

@ -48,8 +48,7 @@ namespace FurnitureAssembly
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue),
FurnitureName = comboBoxProduct.Text,
FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});

View File

@ -139,11 +139,11 @@ namespace FurnitureAssemblyBusinessLogic
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation("Order. OrderId: { Id}. OrderStatus: {OrderStatus} DateCreate: {DateCreate} " +
"FurnitureId:{FurnitureId}. FurnitureName:{FurnitureName}. Count:{ Count}. Sum:{ Sum}. ",
model.Id, model.Status, model.DateCreate, model.FurnitureId, model.FurnitureName, model.Count, model.Sum);
"FurnitureId:{FurnitureId}. Count:{ Count}. Sum:{ 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 });
if (modelView == null)
@ -155,7 +155,6 @@ namespace FurnitureAssemblyBusinessLogic
model.Count = modelView.Count;
model.Sum = modelView.Sum;
model.FurnitureId = model.FurnitureId;
model.FurnitureName = modelView.FurnitureName;
model.Status = modelView.Status;
return model;
}

View File

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

View File

@ -26,7 +26,7 @@ namespace FurnitureAssemblyListImplement.Implements
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
return element.GetViewModel;
return GetOrderViewModel(element);
}
}
return null;
@ -43,7 +43,7 @@ namespace FurnitureAssemblyListImplement.Implements
{
if (model.Id.HasValue && order.Id == model.Id)
{
return order.GetViewModel;
return GetOrderViewModel(order);
}
}
return null;
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Implements
{
if (order.Id.Equals(model.Id))
{
result.Add(order.GetViewModel);
result.Add(GetOrderViewModel(order));
}
}
return result;
@ -68,7 +68,7 @@ namespace FurnitureAssemblyListImplement.Implements
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(order.GetViewModel);
result.Add(GetOrderViewModel(order));
}
return result;
}
@ -89,7 +89,7 @@ namespace FurnitureAssemblyListImplement.Implements
return null;
}
_source.Orders.Add(newOrder);
return newOrder.GetViewModel;
return GetOrderViewModel(newOrder);
}
public OrderViewModel? Update(OrderBindingModel model)
@ -99,10 +99,24 @@ namespace FurnitureAssemblyListImplement.Implements
if (order.Id == model.Id)
{
order.Update(model);
return order.GetViewModel;
return GetOrderViewModel(order);
}
}
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 string FurnitureName { get; private set; } = string.Empty;
public int Count { get; private set; }
public double Sum { get; private set; }
@ -40,7 +38,6 @@ namespace FurnitureAssemblyListImplement.Models
{
Id = model.Id,
FurnitureId = model.FurnitureId,
FurnitureName = model.FurnitureName,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -55,12 +52,8 @@ namespace FurnitureAssemblyListImplement.Models
{
return;
}
FurnitureId = model.FurnitureId;
FurnitureName = model.FurnitureName;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
Status = model.Status;
DateImplement = model.DateImplement;
}
@ -68,7 +61,6 @@ namespace FurnitureAssemblyListImplement.Models
{
Id = Id,
FurnitureId = FurnitureId,
FurnitureName = FurnitureName,
Count = Count,
Sum = Sum,
Status = Status,