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() });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue