ISbd-21 Gordeev I.V. LabWork_05 Base #9

Closed
Igor_Gordeev wants to merge 7 commits from Lab_05 into Lab_04
3 changed files with 22 additions and 8 deletions
Showing only changes of commit 49f7b0b792 - Show all commits

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()
{