все таки поссорились, конфликтные ребята

This commit is contained in:
kamilia 2024-05-06 00:38:02 +04:00
parent 5240a952d7
commit c48424e8e3
2 changed files with 28 additions and 3 deletions

View File

@ -49,7 +49,7 @@ namespace AircraftPlantListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue)
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue || !model.ClientId.HasValue)
{
return result;
}
@ -66,6 +66,14 @@ namespace AircraftPlantListImplement.Implements
return result;
}
if (model.ClientId.HasValue && !model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
result.Add(GetViewModel(order));
}
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
@ -172,6 +180,14 @@ namespace AircraftPlantListImplement.Implements
break;
}
}
foreach (var client in _source.Clients)
{
if (client.Id == order.ClientId)
{
viewModel.ClientFIO = client.ClientFIO;
break;
}
}
return viewModel;
}
}

View File

@ -24,7 +24,7 @@ namespace AircraftPlantFileImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue)
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue || !model.ClientId.HasValue)
{
return new();
}
@ -35,6 +35,13 @@ namespace AircraftPlantFileImplement.Implements
.Select(x => GetViewModel(x))
.ToList();
}
if (model.ClientId.HasValue && !model.Id.HasValue)
{
return _source.Orders
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return _source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
@ -84,7 +91,9 @@ namespace AircraftPlantFileImplement.Implements
{
var viewModel = order.GetViewModel;
var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId);
viewModel.PlaneName = plane?.PlaneName;
viewModel.PlaneName = plane?.PlaneName ?? string.Empty;
var client = _source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
viewModel.ClientFIO = client?.ClientFIO ?? string.Empty;
return viewModel;
}
}