sort api/v1/leave/user/table and api/v1/discipline/complaint_appeal/user/{id}
This commit is contained in:
parent
fb6a82be14
commit
2a02bdf9f7
3 changed files with 123 additions and 7 deletions
|
|
@ -90,7 +90,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("user")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineUser(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineUser(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = null, bool descending = false)
|
||||
{
|
||||
var id = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
|
||||
|
|
@ -125,7 +125,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
data_search = data_search.Where(x => x.Type == type).ToList();
|
||||
if (year != 0)
|
||||
data_search = data_search.Where(x => x.Year == year).ToList();
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -141,11 +141,45 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
ProfileId = x.ProfileId,
|
||||
LastUpdatedAt = x.LastUpdatedAt,
|
||||
CreatedAt = x.CreatedAt
|
||||
})
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
});
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
{
|
||||
if (sortBy == "title")
|
||||
query = descending ? query.OrderByDescending(x => x.Title) : query.OrderBy(x => x.Title);
|
||||
else if (sortBy == "year")
|
||||
query = descending ? query.OrderByDescending(x => x.Year) : query.OrderBy(x => x.Year);
|
||||
else if (sortBy == "status")
|
||||
query = descending ? query.OrderByDescending(x => x.Status) : query.OrderBy(x => x.Status);
|
||||
else if (sortBy == "description")
|
||||
query = descending ? query.OrderByDescending(x => x.Description) : query.OrderBy(x => x.Description);
|
||||
else if (sortBy == "type")
|
||||
query = descending ? query.OrderByDescending(x => x.Type) : query.OrderBy(x => x.Type);
|
||||
else if (sortBy == "caseType")
|
||||
query = descending ? query.OrderByDescending(x => x.CaseType) : query.OrderBy(x => x.CaseType);
|
||||
else if (sortBy == "caseNumber")
|
||||
query = descending ? query.OrderByDescending(x => x.CaseNumber) : query.OrderBy(x => x.CaseNumber);
|
||||
else if (sortBy == "fullname")
|
||||
query = descending ? query.OrderByDescending(x => x.Fullname) : query.OrderBy(x => x.Fullname);
|
||||
else if (sortBy == "citizenId")
|
||||
query = descending ? query.OrderByDescending(x => x.CitizenId) : query.OrderBy(x => x.CitizenId);
|
||||
else if (sortBy == "lastUpdatedAt")
|
||||
query = descending ? query.OrderByDescending(x => x.LastUpdatedAt) : query.OrderBy(x => x.LastUpdatedAt);
|
||||
else if (sortBy == "createdAt")
|
||||
query = descending ? query.OrderByDescending(x => x.CreatedAt) : query.OrderBy(x => x.CreatedAt);
|
||||
else
|
||||
query = query.OrderByDescending(x => x.CreatedAt); // default
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.OrderByDescending(x => x.CreatedAt);
|
||||
}
|
||||
|
||||
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