sort Discipline
This commit is contained in:
parent
d0599aedea
commit
12c8bc5014
11 changed files with 503 additions and 34 deletions
|
|
@ -63,7 +63,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{path}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
// สิทธิ์การเข้าถึง
|
||||
path = path.Trim().ToUpper();
|
||||
|
|
@ -105,7 +105,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
x.Qualification.Contains(keyword)) &&
|
||||
(_permiss != "OWNER" && x.RootDnaId == profile.RootDnaId || _permiss == "OWNER" && true)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -118,7 +118,66 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
Qualification = x.Qualification,
|
||||
TotalInvestigate = x.DisciplineInvestigate_Directors.Count(),
|
||||
TotalDisciplinary = x.DisciplineDisciplinary_DirectorInvestigates.Count(),
|
||||
})
|
||||
});
|
||||
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
if (sortBy == "position")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Position)
|
||||
: query.OrderBy(x => x.Position);
|
||||
}
|
||||
else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName")
|
||||
{
|
||||
query = desc ?
|
||||
query
|
||||
//.OrderByDescending(x => x.Prefix)
|
||||
.OrderByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName) :
|
||||
query
|
||||
//.OrderBy(x => x.Prefix)
|
||||
.OrderBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName);
|
||||
}
|
||||
else if (sortBy == "email")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Email)
|
||||
: query.OrderBy(x => x.Email);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "phone")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Phone)
|
||||
: query.OrderBy(x => x.Phone);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "qualification")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Qualification)
|
||||
: query.OrderBy(x => x.Qualification);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "totalInvestigate")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.TotalInvestigate)
|
||||
: query.OrderBy(x => x.TotalInvestigate);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "totalDisciplinary")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.TotalDisciplinary)
|
||||
: query.OrderBy(x => x.TotalDisciplinary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue