sort Discipline
This commit is contained in:
parent
d0599aedea
commit
12c8bc5014
11 changed files with 503 additions and 34 deletions
|
|
@ -8,14 +8,15 @@ using BMA.EHR.Infrastructure.Persistence;
|
|||
// using BMA.EHR.Placement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Claims;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
||||
{
|
||||
|
|
@ -133,6 +134,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
where x.Title.Contains(keyword) ||
|
||||
(x.Appellant == null ? false : x.Appellant.Contains(keyword))
|
||||
select x).ToList();
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
|
|
@ -165,7 +167,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
|
|
@ -179,11 +181,75 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
Result = x.Result,
|
||||
})
|
||||
.OrderByDescending(x => x.DateConsideration)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
});
|
||||
|
||||
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 "appellant":
|
||||
query = desc ? query.OrderByDescending(x => x.Appellant)
|
||||
: query.OrderBy(x => x.Appellant);
|
||||
break;
|
||||
|
||||
case "offenseDetails":
|
||||
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
||||
: query.OrderBy(x => x.OffenseDetails);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "levelConsideration":
|
||||
query = desc ? query.OrderByDescending(x => x.LevelConsideration)
|
||||
: query.OrderBy(x => x.LevelConsideration);
|
||||
break;
|
||||
|
||||
case "dateConsideration":
|
||||
query = desc ? query.OrderByDescending(x => x.DateConsideration)
|
||||
: query.OrderBy(x => x.DateConsideration);
|
||||
break;
|
||||
|
||||
case "dateReceived":
|
||||
query = desc ? query.OrderByDescending(x => x.DateReceived)
|
||||
: query.OrderBy(x => x.DateReceived);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "result":
|
||||
query = desc ? query.OrderByDescending(x => x.Result)
|
||||
: query.OrderBy(x => x.Result);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.DateConsideration);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
|
|
@ -179,11 +179,75 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสอบสวน
|
||||
DisciplinaryDateStart = x.DisciplinaryDateStart, //วันที่เริ่มการสอบสวน
|
||||
DisciplinaryDateEnd = x.DisciplinaryDateEnd, //วันที่สิ้นสุดการสอบสวน
|
||||
})
|
||||
.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
});
|
||||
|
||||
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 "disciplinaryFaultLevel":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryFaultLevel)
|
||||
: query.OrderBy(x => x.DisciplinaryFaultLevel);
|
||||
break;
|
||||
|
||||
case "disciplinaryCaseFault":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryCaseFault)
|
||||
: query.OrderBy(x => x.DisciplinaryCaseFault);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
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 "disciplinaryDateStart":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
: query.OrderBy(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateEnd":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateEnd)
|
||||
: query.OrderBy(x => x.DisciplinaryDateEnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
|
|
@ -209,11 +209,90 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
ResultDisciplineType = x.ResultDisciplineType,//หน่วยงาย/ส่วนราชการ
|
||||
ResultTitleType = x.ResultTitleType,//ประเภทของเรื่อง
|
||||
ResultYear = x.ResultYear,//ปีงบประมาณ
|
||||
})
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
});
|
||||
|
||||
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 "disciplinaryFaultLevel":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryFaultLevel)
|
||||
: query.OrderBy(x => x.DisciplinaryFaultLevel);
|
||||
break;
|
||||
|
||||
case "disciplinaryCaseFault":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryCaseFault)
|
||||
: query.OrderBy(x => x.DisciplinaryCaseFault);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateStart":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
: query.OrderBy(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateEnd":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateEnd)
|
||||
: query.OrderBy(x => x.DisciplinaryDateEnd);
|
||||
break;
|
||||
|
||||
case "resultOc":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultOc)
|
||||
: query.OrderBy(x => x.ResultOc);
|
||||
break;
|
||||
|
||||
case "resultDisciplineType":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultDisciplineType)
|
||||
: query.OrderBy(x => x.ResultDisciplineType);
|
||||
break;
|
||||
|
||||
case "resultTitleType":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultTitleType)
|
||||
: query.OrderBy(x => x.ResultTitleType);
|
||||
break;
|
||||
|
||||
case "resultYear":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultYear)
|
||||
: query.OrderBy(x => x.ResultYear);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.CreatedAt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ using BMA.EHR.Infrastructure.Persistence;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
||||
|
|
@ -58,7 +59,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineSuspend(DateTime? startDate, DateTime? endDate, int page = 1, int pageSize = 25, string keyword = "", string profileType = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineSuspend(DateTime? startDate, DateTime? endDate, int page = 1, int pageSize = 25, string keyword = "", string profileType = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_SUSPENDED");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -94,7 +95,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
(profileType.ToUpper() == "EMPLOYEE" && x.profileType == "EMPLOYEE")
|
||||
)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -145,13 +146,76 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด
|
||||
profileType = x.profileType,
|
||||
CreatedAt = x.CreatedAt,
|
||||
})
|
||||
.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.CreatedAt)
|
||||
.ThenByDescending(x => x.CitizenId)
|
||||
});
|
||||
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
if (sortBy == "title")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
}
|
||||
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 == "position")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Position)
|
||||
: query.OrderBy(x => x.Position);
|
||||
}
|
||||
else if (sortBy == "positionType" || sortBy == "positionLevel")
|
||||
{
|
||||
query = desc ?
|
||||
query
|
||||
.OrderByDescending(x => x.PositionType)
|
||||
.ThenByDescending(x => x.PositionLevel) :
|
||||
query
|
||||
.OrderBy(x => x.PositionType)
|
||||
.ThenBy(x => x.PositionLevel);
|
||||
}
|
||||
else if (sortBy == "organization")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Organization)
|
||||
: query.OrderBy(x => x.Organization);
|
||||
}
|
||||
else if (sortBy == "startDateSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.StartDateSuspend)
|
||||
: query.OrderBy(x => x.StartDateSuspend);
|
||||
}
|
||||
else if (sortBy == "endDateSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.EndDateSuspend)
|
||||
: query.OrderBy(x => x.EndDateSuspend);
|
||||
}
|
||||
else if (sortBy == "descriptionSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.DescriptionSuspend)
|
||||
: query.OrderBy(x => x.DescriptionSuspend);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.CreatedAt)
|
||||
.ThenByDescending(x => x.CitizenId);
|
||||
}
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public string? levelConsideration { get; set; } // ระดับการพิจารณา
|
||||
public DateTime? dateConsiderationStart { get; set; } // วันที่เริ่มต้นการพิจารณา
|
||||
public DateTime? dateConsiderationEnd { get; set; } // วันที่สิ้นสุดการพิจารณา
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public DateTime? disciplinaryDateEnd { get; set; } // วันที่สิ้นสุดสอบสวน
|
||||
public DateTime? dateReceivedStart { get; set; } // วันที่เริ่มต้นรับเรื่อง
|
||||
public DateTime? dateReceivedEnd { get; set; } // วันที่สิ้นสุดรับเรื่อง
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public DateTime? dateReceivedStart { get; set; } // วันที่เริ่มต้นรับเรื่อง
|
||||
public DateTime? dateReceivedEnd { get; set; } // วันที่สิ้นสุดรับเรื่อง
|
||||
public string? investigationStatusResult { get; set; } // ผลการสืบสวน
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public string? resultTitleType { get; set; } // ประเภทของเรื่อง
|
||||
public string? resultOc { get; set; } // หน่วยงาน/ส่วนราชการ
|
||||
public int? resultYear { get; set; } // ปีงบประมาณ
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue