Доработка чтения названия изделия в заказе, фикс хмл
This commit is contained in:
parent
131521dd59
commit
43c216879b
@ -26,7 +26,7 @@ namespace BlacksmithWorkshopFileImplement
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Manufactures = LoadData(ManufactureFileName, "Manufacture", x => Manufacture.Create(x)!)!;
|
||||
Orders = new List<Order>();
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopFileImplement;
|
||||
using BlacksmithWorkshopFileImplement.Models;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Implements
|
||||
|
@ -16,7 +16,7 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
public List<ManufactureViewModel> GetFullList()
|
||||
{
|
||||
return source.Manufactures
|
||||
.Select(x => new ManufactureViewModel())
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ManufactureViewModel> GetFilteredList(ManufactureSearchModel model)
|
||||
|
@ -3,6 +3,7 @@ using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopFileImplement.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
@ -15,9 +16,16 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders
|
||||
.Select(x => new OrderViewModel())
|
||||
List<OrderViewModel> orderList = new();
|
||||
orderList = source.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
foreach (var order in orderList)
|
||||
{
|
||||
var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty;
|
||||
order.ManufactureName = manufactureName;
|
||||
}
|
||||
return orderList;
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
@ -25,10 +33,17 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
List<OrderViewModel> orderList = new();
|
||||
orderList = source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
foreach (var order in orderList)
|
||||
{
|
||||
var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty;
|
||||
order.ManufactureName = manufactureName;
|
||||
}
|
||||
return orderList;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
|
@ -76,16 +76,19 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
ManufactureComponents = ManufactureComponents
|
||||
};
|
||||
public XElement GetXElement => new
|
||||
("Manufacture",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ManufactureName", ManufactureName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("ManufactureComponents", Components.Select(x => new XElement
|
||||
(
|
||||
"ManufactureComponent",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value)
|
||||
)).ToArray())
|
||||
"Manufacture",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ManufactureName", ManufactureName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("ManufactureComponents", Components.Select
|
||||
(x => new XElement
|
||||
(
|
||||
"ManufactureComponent",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value)
|
||||
)
|
||||
).ToArray())
|
||||
);
|
||||
}
|
||||
}
|
@ -41,12 +41,12 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ManufactureId = Convert.ToInt32(element.Attribute("ManufactureId")!.Value),
|
||||
Count = Convert.ToInt32(element.Attribute("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Attribute("Sum")!.Value),
|
||||
Status = (OrderStatus)Convert.ToInt32(element.Attribute("status")!.Value),
|
||||
DateCreate = Convert.ToDateTime(element.Attribute("DateCreate")!.Value),
|
||||
DateImplement = Convert.ToDateTime(element.Attribute("DateImplement")!.Value)
|
||||
ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value),
|
||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||
DateImplement = Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -75,7 +75,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
(
|
||||
"Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ManufactureID", ManufactureId),
|
||||
new XElement("ManufactureId", ManufactureId),
|
||||
new XElement("Count", Count),
|
||||
new XElement("Sum", Sum),
|
||||
new XElement("Status", (int)Status),
|
||||
|
Loading…
Reference in New Issue
Block a user