Фильтрация по времени
This commit is contained in:
parent
3da62fe249
commit
70560b602e
@ -217,7 +217,7 @@ namespace UniversityClientApp.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
/*[HttpGet]
|
||||||
public IActionResult ReportDisciplines()
|
public IActionResult ReportDisciplines()
|
||||||
{
|
{
|
||||||
if (APIStorekeeper.Client == null)
|
if (APIStorekeeper.Client == null)
|
||||||
@ -225,21 +225,28 @@ namespace UniversityClientApp.Controllers
|
|||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult GetReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
public IActionResult ReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
||||||
{
|
{
|
||||||
if (APIStorekeeper.Client == null)
|
if (APIStorekeeper.Client == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ïîëó÷àåì äàííûå îò ñåðâåðà
|
// Ïîëó÷àåì äàííûå îò ñåðâåðà
|
||||||
//var reportData = APIStorekeeper.GetRequest<List<ReportDisciplineViewModel>>($"api/disciplines/GetReportDisciplines?datefrom={dateFrom}&dateto={dateTo}");
|
//var reportData = APIStorekeeper.GetRequest<List<ReportDisciplineViewModel>>($"api/disciplines/GetReportDisciplines?datefrom={dateFrom}&dateto={dateTo}");
|
||||||
var reportData = APIStorekeeper.GetRequest<List<ReportDisciplineViewModel>>($"api/discipline/getreportdisciplines");
|
|
||||||
// Ïåðåäàåì äàííûå â ÷àñòè÷íîå ïðåäñòàâëåíèå
|
// Ïåðåäàåì äàííûå â ÷àñòè÷íîå ïðåäñòàâëåíèå
|
||||||
return PartialView("ReportDisciplines", reportData);
|
if (dateFrom == DateOnly.MinValue || dateTo == DateOnly.MaxValue)
|
||||||
|
{
|
||||||
|
return View("ReportDisciplines", null);
|
||||||
|
}
|
||||||
|
var reportData = APIStorekeeper.GetRequest<List<ReportDisciplineViewModel>>($"api/discipline/getreportdisciplines?datefrom={dateFrom:yyyy-MM-dd}&dateto={dateTo:yyyy-MM-dd}");
|
||||||
|
|
||||||
|
return View("ReportDisciplines", reportData);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@using UniversityContracts.ViewModels
|
@using UniversityContracts.ViewModels
|
||||||
@model List<ReportDisciplineViewModel>
|
@model List<ReportDisciplineViewModel>
|
||||||
|
|
||||||
<form method="get" action="/Home/GetReportDisciplines">
|
<form method="get" action="/Home/ReportDisciplines">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Отчёт за период по дисциплинам</h2>
|
<h2 class="display-4">Отчёт за период по дисциплинам</h2>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,11 +94,25 @@ namespace UniversityDatabaseImplement.Implements
|
|||||||
query = query.Where(x => x.TeacherId == model.TeacherId.Value);
|
query = query.Where(x => x.TeacherId == model.TeacherId.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
|
||||||
|
|
||||||
|
/*if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value);
|
query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
var x = query.Select(x => x.GetViewModel).ToList();
|
||||||
|
var res = new List<DisciplineViewModel>();
|
||||||
|
|
||||||
|
foreach (var item in x) {
|
||||||
|
if (item.Date > model.DateFrom && item.Date < model.DateTo)
|
||||||
|
{
|
||||||
|
res.Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return query.Select(x => x.GetViewModel).ToList();
|
|
||||||
|
//return query.Select(x => x.GetViewModel).ToList();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,21 +33,21 @@ namespace UniversityRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*[HttpPost]
|
|
||||||
public List<ReportDisciplineViewModel> GetReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _reportLogic.GetDisciplines(new ReportDateRangeBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения списка дисциплин");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
public List<ReportDisciplineViewModel> GetReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _reportLogic.GetDisciplines(new ReportDateRangeBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка дисциплин");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
public List<ReportDisciplineViewModel> GetReportDisciplines()
|
public List<ReportDisciplineViewModel> GetReportDisciplines()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user