This commit is contained in:
2025-11-12 16:20:51 +08:00
parent 5ae262205c
commit cd05ad2305
3 changed files with 42 additions and 47 deletions

View File

@@ -224,7 +224,7 @@ public class activityController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.activity q, int page, int pageSize = 10, public IHttpActionResult GetList([FromBody] Model.ViewModel.activity q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false) string sortBy = "", bool sortDesc = false)
{ {
var qry = _db.activities.AsQueryable(); var qry = _db.activities.AsEnumerable();
if (!string.IsNullOrEmpty(q.subject)) if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject)); qry = qry.Where(o => o.subject.Contains(q.subject));
if (q.kind.HasValue && q.kind > 0) if (q.kind.HasValue && q.kind > 0)
@@ -281,10 +281,10 @@ public class activityController : ApiController
qry = qry.OrderByDescending(o => o.num); qry = qry.OrderByDescending(o => o.num);
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize); var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qry.Select(x => new list = qryList.Select(x => new
{ {
num = x.num, num = x.num,
subject = x.subject, subject = x.subject,
@@ -348,7 +348,7 @@ public class activityController : ApiController
////var qry = _db.actItems.Where(a => a.IsDel == false).AsEnumerable();////不確定是否新增欄位? 先註解 ////var qry = _db.actItems.Where(a => a.IsDel == false).AsEnumerable();////不確定是否新增欄位? 先註解
var qry = _db.actItems.AsQueryable(); var qry = _db.actItems.AsEnumerable();
if (!string.IsNullOrEmpty(q.subject)) if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject.Trim())); qry = qry.Where(o => o.subject.Contains(q.subject.Trim()));
@@ -364,7 +364,7 @@ public class activityController : ApiController
} }
if (!string.IsNullOrEmpty(q.kindTxt)) if (!string.IsNullOrEmpty(q.kindTxt))
qry = qry.Where(o => o.actItem_kind?.kind != null && o.actItem_kind.kind.Contains(q.kindTxt)); qry = qry.Where(o => o.actItem_kind != null && o.actItem_kind.kind != null && o.actItem_kind.kind.Contains(q.kindTxt));
if (q.category.HasValue && q.category.Value > 0) if (q.category.HasValue && q.category.Value > 0)
qry = qry.Where(o => o.category == q.category.Value); qry = qry.Where(o => o.category == q.category.Value);
if (!string.IsNullOrEmpty(q.categorys)) if (!string.IsNullOrEmpty(q.categorys))
@@ -410,10 +410,10 @@ public class activityController : ApiController
var tdesc = publicFun.enum_desc<Model.activity.category>(); var tdesc = publicFun.enum_desc<Model.activity.category>();
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize); var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qry.Select(x => new list = qryList.Select(x => new
{ {
num = x.num, num = x.num,
subject = x.subject, subject = x.subject,
@@ -731,16 +731,15 @@ public class activityController : ApiController
if (this_id > 0) if (this_id > 0)
{ {
//檢查 //檢查
var qry = _db.activity_kind_detail.AsQueryable(); var qry = _db.activity_kind_detail.Where(o => o.activity_kind_num == this_id);
qry = qry.Where(o => o.activity_kind_num == this_id);
int i = 1; int i = 1;
//已有值 //已有值
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize); var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qry.Select(x => new list = qryList.Select(x => new
{ {
id = i++, id = i++,
num = x.num, num = x.num,
@@ -927,13 +926,12 @@ public class activityController : ApiController
if (kind > 0) if (kind > 0)
{ {
int i = 1; int i = 1;
var qry2 = _db.activity_kind_detail.AsQueryable(); var qry2 = _db.activity_kind_detail.Where(o => o.activity_kind_num == kind);
qry2 = qry2.Where(o => o.activity_kind_num == kind);
var count2 = qry2.Count(); //pageSize = count2;//一次取回?? var count2 = qry2.Count(); //pageSize = count2;//一次取回??
if (pageSize > 0) qry2 = qry2.ToPagedList(page, pageSize); var qry2List = (pageSize > 0) ? qry2.ToPagedList(page, pageSize).ToList() : qry2.ToList();
var ret = new var ret = new
{ {
list = qry2.Select(x => new list = qry2List.Select(x => new
{ {
id = i++, id = i++,
num = 0, num = 0,
@@ -1176,18 +1174,15 @@ public class activityController : ApiController
int kind = prod.kind ?? 0; //分類 int kind = prod.kind ?? 0; //分類
var qry1 = _db.activity_spares.AsQueryable(); var qry1 = _db.activity_spares.Where(o => o.activity_num == this_act_id).OrderBy(o => o.num);
qry1 = qry1.Where(o => o.activity_num == this_act_id);
qry1 = qry1.OrderBy(o => o.num);
var count = qry1.Count(); //pageSize = count;//一次取回?? var count = qry1.Count(); //pageSize = count;//一次取回??
int i = 1; int i = 1;
if (pageSize > 0) qry1 = qry1.ToPagedList(page, pageSize); var qry1List = (pageSize > 0) ? qry1.ToPagedList(page, pageSize).ToList() : qry1.ToList();
var ret = new var ret = new
{ {
list = qry1.Select(x => new list = qry1List.Select(x => new
{ {
id = i++, id = i++,
num = x.num, num = x.num,
@@ -1331,7 +1326,7 @@ public class activityController : ApiController
string sortBy = "", bool sortDesc = false) string sortBy = "", bool sortDesc = false)
{ {
var qry = _db.activity_check.AsQueryable(); var qry = _db.activity_check.AsEnumerable();
if (!string.IsNullOrEmpty(q.activityTxt)) if (!string.IsNullOrEmpty(q.activityTxt))
qry = qry.Where(o => o.activity.subject.Contains(q.activityTxt.Trim())); qry = qry.Where(o => o.activity.subject.Contains(q.activityTxt.Trim()));
@@ -1388,10 +1383,10 @@ public class activityController : ApiController
var tdesc = publicFun.enum_desc<Model.activity_check.keyin1>(); var tdesc = publicFun.enum_desc<Model.activity_check.keyin1>();
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize); var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qry.Select(x => new list = qryList.Select(x => new
{ {
num = x.num, num = x.num,
subject = x.activity?.subject, subject = x.activity?.subject,
@@ -1466,7 +1461,7 @@ public class activityController : ApiController
qry = qry.Where(o => o.reg_time < Convert.ToDateTime(q.reg_time2.Value).AddDays(1)); qry = qry.Where(o => o.reg_time < Convert.ToDateTime(q.reg_time2.Value).AddDays(1));
qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate?.Date.CompareTo(_now) <= 180)); qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate.HasValue && o.dueDate.Value.Date.CompareTo(_now) <= 180));
qry = qry.OrderByDescending(o => o.num); qry = qry.OrderByDescending(o => o.num);
@@ -1518,10 +1513,10 @@ public class activityController : ApiController
qry = qry.OrderBy(O => O.kind).ThenBy(o => o.num); qry = qry.OrderBy(O => O.kind).ThenBy(o => o.num);
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize); var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qry.Select(x => new list = qryList.Select(x => new
{ {
num = x.num, num = x.num,
kind = x.kind, kind = x.kind,

View File

@@ -220,32 +220,32 @@ public class orderController : ApiController
if (!string.IsNullOrEmpty(q.address)) if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim())); qry = qry.Where(o => o.address.Contains(q.address.Trim()));
if (!string.IsNullOrEmpty(q.subject)) if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject?.Trim())); qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject.Trim()));
if (!string.IsNullOrEmpty(q.u_name)) if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name?.Trim())); qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name.Trim()));
if (!string.IsNullOrEmpty(q.introducerTxt)) if (!string.IsNullOrEmpty(q.introducerTxt))
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt?.Trim())); qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt.Trim()));
if (!string.IsNullOrEmpty(q.actItemTxt)) if (!string.IsNullOrEmpty(q.actItemTxt))
{ {
//qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0); //qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0);
// qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0); // qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt?.Trim())).Count() > 0); qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt.Trim())).Count() > 0);
} }
if (!string.IsNullOrEmpty(q.country)) if (!string.IsNullOrEmpty(q.country))
qry = qry.Where(o => o.f_num != null && o.follower?.country == q.country); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == q.country);
if (!string.IsNullOrEmpty(q.country2)) if (!string.IsNullOrEmpty(q.country2))
{ {
if (q.country2 == "1") if (q.country2 == "1")
{ {
qry = qry.Where(o => o.f_num != null && o.follower?.country == "158"); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == "158");
} }
else if (q.country2 == "2") else if (q.country2 == "2")
{ {
qry = qry.Where(o => o.f_num != null && o.follower?.country != "158"); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country != "158");
} }
} }
@@ -275,16 +275,16 @@ public class orderController : ApiController
else if (sortBy.Equals("u_name")) else if (sortBy.Equals("u_name"))
{ {
if (sortDesc) if (sortDesc)
qry = qry.OrderByDescending(o => o.follower?.u_name); qry = qry.OrderByDescending(o => o.follower != null ? o.follower.u_name : "");
else else
qry = qry.OrderBy(o => o.follower?.u_name); qry = qry.OrderBy(o => o.follower != null ? o.follower.u_name : "");
} }
else if (sortBy.Equals("subject")) else if (sortBy.Equals("subject"))
{ {
if (sortDesc) if (sortDesc)
qry = qry.OrderByDescending(o => o.activity?.subject); qry = qry.OrderByDescending(o => o.activity != null ? o.activity.subject : "");
else else
qry = qry.OrderBy(o => o.activity?.subject); qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : "");
} }
else else
qry = qry.OrderByDescending(o => o.reg_time); qry = qry.OrderByDescending(o => o.reg_time);
@@ -802,7 +802,7 @@ public class orderController : ApiController
//家族 : 家長是我的人,跟我同家長的人,我的家長本人,我本人 //家族 : 家長是我的人,跟我同家長的人,我的家長本人,我本人
var ccList = _db.followers.Where(x => x.num == _follower || x.leader == _follower).Select(x => x.num).ToList(); var ccList = _db.followers.Where(x => x.num == _follower || x.leader == _follower).Select(x => x.num).ToList();
var qry = _db.followers.Where(f => ccList.Contains(f.num) || ccList.Contains(f.leader)); var qry = _db.followers.Where(f => ccList.Contains(f.num) || (f.leader.HasValue && ccList.Contains(f.leader.Value)));
//未付款資料 //未付款資料
var unpayDt = _db.pro_order_detail.AsQueryable(); var unpayDt = _db.pro_order_detail.AsQueryable();

View File

@@ -199,7 +199,7 @@ public class apporderController : ApiController
string sortBy = "", bool sortDesc = false) string sortBy = "", bool sortDesc = false)
{ {
var qry = _db.pro_order.AsQueryable(); var qry = _db.pro_order.AsEnumerable();
//var aIDt = _db.actItems.Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項 //var aIDt = _db.actItems.Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項
@@ -218,32 +218,32 @@ public class apporderController : ApiController
if (!string.IsNullOrEmpty(q.address)) if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim())); qry = qry.Where(o => o.address.Contains(q.address.Trim()));
if (!string.IsNullOrEmpty(q.subject)) if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject?.Trim())); qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject.Trim()));
if (!string.IsNullOrEmpty(q.u_name)) if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name?.Trim())); qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name.Trim()));
if (!string.IsNullOrEmpty(q.introducerTxt)) if (!string.IsNullOrEmpty(q.introducerTxt))
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt?.Trim())); qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt.Trim()));
if (!string.IsNullOrEmpty(q.actItemTxt)) if (!string.IsNullOrEmpty(q.actItemTxt))
{ {
//qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0); //qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0);
// qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0); // qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt?.Trim())).Count() > 0); qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt.Trim())).Count() > 0);
} }
if (!string.IsNullOrEmpty(q.country)) if (!string.IsNullOrEmpty(q.country))
qry = qry.Where(o => o.f_num != null && o.follower?.country == q.country); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == q.country);
if (!string.IsNullOrEmpty(q.country2)) if (!string.IsNullOrEmpty(q.country2))
{ {
if (q.country2 == "1") if (q.country2 == "1")
{ {
qry = qry.Where(o => o.f_num != null && o.follower?.country == "158"); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == "158");
} }
else if (q.country2 == "2") else if (q.country2 == "2")
{ {
qry = qry.Where(o => o.f_num != null && o.follower?.country != "158"); qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country != "158");
} }
} }