STAGE 2 OK
This commit is contained in:
@@ -44,22 +44,25 @@ public class countryController : BaseApiController
|
||||
public IHttpActionResult GetList([FromBody] Model.ViewModel.country q,
|
||||
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.countries.AsEnumerable();
|
||||
var qry = _db.countries.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(q.keyword))
|
||||
qry = qry.Where(o => o.ID.Contains(q.keyword.Trim()) || o.name_en.Contains(q.keyword.Trim()) || o.name_zh.Contains(q.keyword.Trim()));
|
||||
|
||||
qry = qry.OrderBy(o => o.range).ThenBy(o => o.name_en);
|
||||
|
||||
var count = qry.Count();
|
||||
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
|
||||
|
||||
var ret = new
|
||||
{
|
||||
list = qry.ToPagedList(page, pageSize).Select(x => new
|
||||
list = qryList.Select(x => new
|
||||
{
|
||||
id = x.ID,
|
||||
name_en = x.name_en,
|
||||
name_zh = x.name_zh,
|
||||
}),
|
||||
count = qry.Count()
|
||||
count = count
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user