sort Discipline

This commit is contained in:
Adisak 2025-10-06 16:28:16 +07:00
parent d0599aedea
commit 12c8bc5014
11 changed files with 503 additions and 34 deletions

View file

@ -160,7 +160,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.ToList();
}
var data = data_search
var query = data_search
.Select(x => new
{
Id = x.Id,//id ข้อมูลเรื่องสืบสวน
@ -174,11 +174,76 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสืบสวน
InvestigationDetail = x.InvestigationDetail,
InvestigationStatusResult = x.InvestigationStatusResult,
})
.OrderByDescending(x => x.InvestigationDateStart)
});
bool desc = req.descending ?? false;
if (!string.IsNullOrEmpty(req.sortBy))
{
switch (req.sortBy)
{
case "title":
query = desc ? query.OrderByDescending(x => x.Title)
: query.OrderBy(x => x.Title);
break;
case "respondentType":
query = desc ? query.OrderByDescending(x => x.RespondentType)
: query.OrderBy(x => x.RespondentType);
break;
case "offenseDetails":
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
: query.OrderBy(x => x.OffenseDetails);
break;
case "status":
query = desc ? query.OrderByDescending(x => x.Status)
: query.OrderBy(x => x.Status);
break;
case "investigationDateStart":
query = desc ? query.OrderByDescending(x => x.InvestigationDateStart)
: query.OrderBy(x => x.InvestigationDateStart);
break;
case "investigationDateEnd":
query = desc ? query.OrderByDescending(x => x.InvestigationDateEnd)
: query.OrderBy(x => x.InvestigationDateEnd);
break;
case "dateReceived":
query = desc ? query.OrderByDescending(x => x.DateReceived)
: query.OrderBy(x => x.DateReceived);
break;
case "createdAt":
query = desc ? query.OrderByDescending(x => x.CreatedAt)
: query.OrderBy(x => x.CreatedAt);
break;
case "investigationDetail":
query = desc ? query.OrderByDescending(x => x.InvestigationDetail)
: query.OrderBy(x => x.InvestigationDetail);
break;
case "investigationStatusResult":
query = desc ? query.OrderByDescending(x => x.InvestigationStatusResult)
: query.OrderBy(x => x.InvestigationStatusResult);
break;
default:
query = query.OrderByDescending(x => x.InvestigationDateStart);
break;
}
}
var data = query
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList();
return Success(new { data, total = data_search.Count() });
}