Исправление: вычисляемое поле и метод апдейт
This commit is contained in:
parent
a15b380638
commit
0c29f24758
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemFileImplement.Implements
|
||||
{
|
||||
@ -21,7 +22,7 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders.Select(x => x.GetViewModel).ToList();
|
||||
return source.Orders.Select(x => GetOrderViewModel(x)).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
@ -32,7 +33,7 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id.Equals(model.Id))
|
||||
.Select(x => x.GetViewModel)
|
||||
.Select(x => GetOrderViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@ -42,11 +43,10 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return source.Orders
|
||||
var order = source.Orders
|
||||
.FirstOrDefault(x =>
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
(model.Id.HasValue && x.Id == model.Id));
|
||||
return GetOrderViewModel(order);
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -59,7 +59,7 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return newOrder.GetViewModel;
|
||||
return GetOrderViewModel(newOrder);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -71,7 +71,7 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return order.GetViewModel;
|
||||
return GetOrderViewModel(order);
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
@ -81,9 +81,23 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return element.GetViewModel;
|
||||
return GetOrderViewModel(element);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ namespace FurnitureAssemFileImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureId = model.FurnitureId,
|
||||
FurnitureName = model.FurnitureName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -60,7 +59,6 @@ namespace FurnitureAssemFileImplement.Models
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
||||
FurnitureName = element.Element("FurnitureName")!.Value,
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
|
||||
@ -83,12 +81,8 @@ namespace FurnitureAssemFileImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
FurnitureId = model.FurnitureId;
|
||||
FurnitureName = model.FurnitureName;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
@ -96,7 +90,6 @@ namespace FurnitureAssemFileImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureId = FurnitureId,
|
||||
FurnitureName = FurnitureName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
@ -107,7 +100,6 @@ namespace FurnitureAssemFileImplement.Models
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("FurnitureId", FurnitureId),
|
||||
new XElement("FurnitureName", FurnitureName),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
|
Loading…
Reference in New Issue
Block a user