增加客堂簡易報名
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using PagedList;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
@@ -17,4 +19,37 @@ public class preOrderController: ApiController
|
||||
// TODO: 在這裡新增建構函式邏輯
|
||||
//
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("api/preOrder/GetPreOrder")]
|
||||
|
||||
public IHttpActionResult GetPreOrder([FromBody] Model.ViewModel.preOrder pre, int page, int pageSize = 10,
|
||||
string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry=_db.pre_order.AsQueryable();
|
||||
if (!string.IsNullOrEmpty(pre.f_name))
|
||||
{
|
||||
qry = qry.Where(x => _db.followers.Where(y => y.u_name == pre.f_name).Select(y => y.num).ToList().Contains((int)x.f_num));
|
||||
}
|
||||
sortBy = sortBy ?? string.Empty;
|
||||
var count = qry.Count(); //pageSize = count;//一次取回??
|
||||
if (pageSize == -1)
|
||||
{
|
||||
pageSize = count;
|
||||
}
|
||||
if (pageSize == 0)
|
||||
pageSize = 10;
|
||||
var ret = new
|
||||
{
|
||||
list = qry.ToPagedList(page, pageSize).Select(x => new
|
||||
{
|
||||
x.num,x.f_num,x.admin_num,x.order_no,x.item_count,x.total_amt,x.reg_time,x.receipt_num,x.act_num,
|
||||
f_name=_db.followers.Where(z=>z.num==x.f_num).Select(z=>z.u_name).FirstOrDefault(),
|
||||
act_name=_db.activities.Where(w=>w.num==x.act_num).Select(w=>w.subject).FirstOrDefault(),
|
||||
}).ToList(),
|
||||
count = count
|
||||
};
|
||||
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user