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 Redirect("~/Home/Enter");
} }
return return View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
} }
[HttpGet] [HttpGet]
public IActionResult Privacy() public IActionResult Privacy()

View File

@ -6,7 +6,7 @@ namespace SushiBarContracts.SearchModels
public int? Id { get; set; } public int? Id { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public DateTime? DateFrom { 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) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
using var context = new SushiBarDatabase(); using var context = new SushiBarDatabase();
if (!model.Id.HasValue && (model.DateFrom == null || model.DateTo == null)) if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return new();
}
else
{ {
return context.Orders return context.Orders
.Include(x => x.Sushi) .Include(x => x.Sushi)
@ -53,6 +49,25 @@ namespace SushiBarDatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .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() public List<OrderViewModel> GetFullList()
{ {