sort Discipline
This commit is contained in:
parent
d0599aedea
commit
12c8bc5014
11 changed files with 503 additions and 34 deletions
|
|
@ -746,7 +746,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("admin")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineAdmin(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineAdmin(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_APPEAL");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -812,7 +812,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
data_search = data_search
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -828,12 +828,76 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
ProfileId = x.ProfileId,
|
||||
LastUpdatedAt = x.LastUpdatedAt,
|
||||
profileType = x.profileType
|
||||
})
|
||||
.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.LastUpdatedAt)
|
||||
});
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
switch (sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "description":
|
||||
query = desc ? query.OrderByDescending(x => x.Description)
|
||||
: query.OrderBy(x => x.Description);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "type":
|
||||
query = desc ? query.OrderByDescending(x => x.Type)
|
||||
: query.OrderBy(x => x.Type);
|
||||
break;
|
||||
|
||||
case "year":
|
||||
query = desc ? query.OrderByDescending(x => x.Year)
|
||||
: query.OrderBy(x => x.Year);
|
||||
break;
|
||||
|
||||
case "caseType":
|
||||
query = desc ? query.OrderByDescending(x => x.CaseType)
|
||||
: query.OrderBy(x => x.CaseType);
|
||||
break;
|
||||
|
||||
case "caseNumber":
|
||||
query = desc ? query.OrderByDescending(x => x.CaseNumber)
|
||||
: query.OrderBy(x => x.CaseNumber);
|
||||
break;
|
||||
|
||||
case "fullname":
|
||||
query = desc ? query.OrderByDescending(x => x.Fullname)
|
||||
: query.OrderBy(x => x.Fullname);
|
||||
break;
|
||||
|
||||
case "lastUpdatedAt":
|
||||
query = desc ? query.OrderByDescending(x => x.LastUpdatedAt)
|
||||
: query.OrderBy(x => x.LastUpdatedAt);
|
||||
break;
|
||||
|
||||
case "profileType":
|
||||
query = desc ? query.OrderByDescending(x => x.profileType)
|
||||
: query.OrderBy(x => x.profileType);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query
|
||||
.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.LastUpdatedAt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue