ПИбд-22 Боровков М В 6 лабораторная работа #7
@ -16,7 +16,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Select(x => AccessClientStorage(AccessSushiStorage(x.GetViewModel))!)
|
.Select(x => AccessStorage(x.GetViewModel))!
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -27,7 +27,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
(!model.DateFrom.HasValue || o.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || o.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || o.DateCreate <= model.DateTo) &&
|
(!model.DateTo.HasValue || o.DateCreate <= model.DateTo) &&
|
||||||
(!model.ClientId.HasValue || o.ClientId == model.ClientId))
|
(!model.ClientId.HasValue || o.ClientId == model.ClientId))
|
||||||
.Select(o => AccessClientStorage(AccessSushiStorage(o.GetViewModel))!)
|
.Select(o => AccessStorage(o.GetViewModel)!)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
@ -36,9 +36,8 @@ namespace SushiBarFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return AccessClientStorage(AccessSushiStorage(
|
return AccessStorage(source.Orders
|
||||||
source.Orders
|
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel!);
|
||||||
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel));
|
|
||||||
}
|
}
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -50,7 +49,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
}
|
}
|
||||||
source.Orders.Add(newOrder);
|
source.Orders.Add(newOrder);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessClientStorage(AccessSushiStorage(newOrder.GetViewModel));
|
return AccessStorage(newOrder.GetViewModel);
|
||||||
}
|
}
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -61,7 +60,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
}
|
}
|
||||||
element.Update(model);
|
element.Update(model);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessClientStorage(AccessSushiStorage(element.GetViewModel));
|
return AccessStorage(element.GetViewModel);
|
||||||
}
|
}
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -70,32 +69,23 @@ namespace SushiBarFileImplement.Implements
|
|||||||
{
|
{
|
||||||
source.Orders.Remove(element);
|
source.Orders.Remove(element);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessClientStorage(AccessSushiStorage(element.GetViewModel));
|
return AccessStorage(element.GetViewModel);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public OrderViewModel? AccessSushiStorage(OrderViewModel? model)
|
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return null;
|
|
||||||
foreach (var iceCream in source.Sushis)
|
|
||||||
{
|
|
||||||
if (iceCream.Id == model.SushiId)
|
|
||||||
{
|
|
||||||
model.SushiName = iceCream.SushiName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? AccessClientStorage(OrderViewModel? model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return null;
|
return null;
|
||||||
|
var sushi = source.Sushis.FirstOrDefault(x => x.Id == model.Id);
|
||||||
var client = source.Clients.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 (sushi != null)
|
||||||
|
model.SushiName = sushi.SushiName;
|
||||||
if (client != null)
|
if (client != null)
|
||||||
model.ClientFIO = client.ClientFIO;
|
model.ClientFIO = client.ClientFIO;
|
||||||
|
if (implementer != null)
|
||||||
|
model.ImplementerName = implementer.ImplementerFIO;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user