Full done

This commit is contained in:
Игорь Гордеев 2024-05-12 17:51:34 +04:00
parent 44b11867c9
commit 49f7b0b792
3 changed files with 22 additions and 8 deletions

View File

@ -20,8 +20,7 @@ namespace SushiBarClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
}
[HttpGet]
public IActionResult Privacy()

View File

@ -6,7 +6,7 @@ namespace SushiBarContracts.SearchModels
public int? Id { get; set; }
public DateTime? DateTo { get; set; }
public DateTime? DateFrom { get; set; }
public int ClientId { get; set; }
public int? ClientId { get; set; }
}
}

View File

@ -40,11 +40,7 @@ namespace SushiBarDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
using var context = new SushiBarDatabase();
if (!model.Id.HasValue && (model.DateFrom == null || model.DateTo == null))
{
return new();
}
else
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Orders
.Include(x => x.Sushi)
@ -53,6 +49,25 @@ namespace SushiBarDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Id.HasValue)
{
return context.Orders
.Include(x => x.Sushi)
.Include(x => x.Client)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Sushi)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public List<OrderViewModel> GetFullList()
{