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