и снова

This commit is contained in:
bekodeg 2024-05-21 21:13:55 +04:00
parent f203356284
commit fd64893544
3 changed files with 22 additions and 9 deletions

View File

@ -28,6 +28,7 @@ namespace SushiBarFileImplement.Models
Id = model.Id,
SushiId = model.SushiId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -46,6 +47,7 @@ namespace SushiBarFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value.ToString()),
@ -68,6 +70,7 @@ namespace SushiBarFileImplement.Models
Id = Id,
SushiId = SushiId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
@ -78,6 +81,7 @@ namespace SushiBarFileImplement.Models
new XAttribute("Id", Id),
new XElement("SushiId", SushiId),
new XElement("ClientId", ClientId),
new XElement("ImplementerId", ClientId),
new XElement("Count", Count),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),

View File

@ -18,7 +18,7 @@ namespace SushiBarListImplement.Implements
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(AccessClientStorage(AccessSushiStorage(order.GetViewModel)));
result.Add(AccessStorage(order.GetViewModel));
}
return result;
}
@ -31,7 +31,7 @@ namespace SushiBarListImplement.Implements
(model.DateFrom.HasValue && model.DateTo.HasValue &&
model.DateFrom < order.DateCreate && order.DateCreate < model.DateTo))
{
result.Add(AccessClientStorage(AccessSushiStorage(order.GetViewModel)));
result.Add(AccessStorage(order.GetViewModel));
}
}
return result;
@ -46,7 +46,7 @@ namespace SushiBarListImplement.Implements
{
if (model.Id.HasValue && order.Id == model.Id)
{
return AccessClientStorage(AccessSushiStorage(order.GetViewModel));
return AccessStorage(order.GetViewModel);
}
}
return null;
@ -67,7 +67,7 @@ namespace SushiBarListImplement.Implements
return null;
}
_source.Orders.Add(newOrder);
return AccessClientStorage(AccessSushiStorage(newOrder.GetViewModel));
return AccessStorage(newOrder.GetViewModel);
}
public OrderViewModel? Update(OrderBindingModel model)
{
@ -76,7 +76,7 @@ namespace SushiBarListImplement.Implements
if (order.Id == model.Id)
{
order.Update(model);
return AccessClientStorage(AccessSushiStorage(order.GetViewModel));
return AccessStorage(order.GetViewModel);
}
}
return null;
@ -89,7 +89,7 @@ namespace SushiBarListImplement.Implements
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
return AccessClientStorage(AccessSushiStorage(element.GetViewModel));
return AccessStorage(element.GetViewModel);
}
}
return null;
@ -107,11 +107,17 @@ namespace SushiBarListImplement.Implements
return model;
}
public OrderViewModel AccessClientStorage(OrderViewModel model)
public OrderViewModel AccessStorage(OrderViewModel model)
{
var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId);
var iceCream = _source.Sushis.FirstOrDefault(x => x.Id == model.Id);
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
if (iceCream != null)
model.SushiName = iceCream.SushiName;
if (client != null)
model.ClientFIO = client.ClientFIO;
if (implementer != null)
model.ImplementerName = implementer.ImplementerFIO;
return model;
}
}

View File

@ -30,7 +30,8 @@ namespace SushiBarListImplement.Models
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
DateImplement = model.DateImplement,
ImplementerId = model.ImplementerId
};
}
public void Update(OrderBindingModel? model)
@ -41,6 +42,7 @@ namespace SushiBarListImplement.Models
}
SushiId = model.SushiId;
ClientId = model.ClientId;
ImplementerId = model.ImplementerId;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
@ -51,6 +53,7 @@ namespace SushiBarListImplement.Models
Id = Id,
SushiId = SushiId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,