Laba2 Base PIbd-22 Kalyshev Y V #2

Closed
Zyzf wants to merge 2 commits from Laba2 into Laba1
3 changed files with 10 additions and 15 deletions
Showing only changes of commit b3208294f8 - Show all commits

View File

@ -62,8 +62,7 @@ namespace BlacksmithWorkshopFileImplement.Implements
}
public ComponentViewModel? Update(ComponentBindingModel model)
{
var component = source.Components.FirstOrDefault(x => x.Id ==
model.Id);
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
@ -74,8 +73,7 @@ namespace BlacksmithWorkshopFileImplement.Implements
}
public ComponentViewModel? Delete(ComponentBindingModel model)
{
var element = source.Components.FirstOrDefault(x => x.Id ==
model.Id);
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Components.Remove(element);

View File

@ -56,11 +56,8 @@ namespace BlacksmithWorkshopFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ManufactureName = element.Element("ManufactureName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Components =
element.Element("ManufactureComponents")!.Elements("ManufactureComponent")
.ToDictionary(x =>
Convert.ToInt32(x.Element("Key")?.Value), x =>
Convert.ToInt32(x.Element("Value")?.Value))
Components = element.Element("ManufactureComponents")!.Elements("ManufactureComponent")
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(ManufactureBindingModel model)
@ -81,7 +78,7 @@ namespace BlacksmithWorkshopFileImplement.Models
Price = Price,
ManufactureComponents = ManufactureComponents
};
public XElement GetXElement => new("Product",
public XElement GetXElement => new("Manufacture",
new XAttribute("Id", Id),
new XElement("ManufactureName", ManufactureName),
new XElement("Price", Price.ToString()),

View File

@ -16,6 +16,7 @@ namespace BlacksmithWorkshopFileImplement.Models
{
public int Id { get; private set; }
public int ManufactureId { get; private set; }
public string ManufactureName { get; private set; } = string.Empty;
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@ -32,6 +33,7 @@ namespace BlacksmithWorkshopFileImplement.Models
{
Id = model.Id,
ManufactureId = model.ManufactureId,
ManufactureName = model.ManufactureName,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -50,6 +52,7 @@ namespace BlacksmithWorkshopFileImplement.Models
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value),
ManufactureName = element.Element("ManufactureName")!.Value,
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
@ -64,12 +67,7 @@ namespace BlacksmithWorkshopFileImplement.Models
{
return;
}
Id = model.Id;
ManufactureId = model.ManufactureId;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement;
}
@ -77,6 +75,7 @@ namespace BlacksmithWorkshopFileImplement.Models
{
Id = Id,
ManufactureId = ManufactureId,
ManufactureName = ManufactureName,
Count = Count,
Sum = Sum,
Status = Status,
@ -88,6 +87,7 @@ namespace BlacksmithWorkshopFileImplement.Models
"Order",
new XAttribute("Id", Id),
new XElement("ManufactureId", ManufactureId.ToString()),
new XElement("ManufactureName", ManufactureName.ToString()),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),