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,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.activities.AsQueryable();
var qry = _db.activities.AsEnumerable();
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject));
if (q.kind.HasValue && q.kind > 0)
@@ -281,10 +281,10 @@ public class activityController : ApiController
qry = qry.OrderByDescending(o => o.num);
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
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
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.AsQueryable();
var qry = _db.actItems.AsEnumerable();
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject.Trim()));
@@ -364,7 +364,7 @@ public class activityController : ApiController
}
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)
qry = qry.Where(o => o.category == q.category.Value);
if (!string.IsNullOrEmpty(q.categorys))
@@ -410,10 +410,10 @@ public class activityController : ApiController
var tdesc = publicFun.enum_desc<Model.activity.category>();
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
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.subject,
@@ -731,16 +731,15 @@ public class activityController : ApiController
if (this_id > 0)
{
//檢查
var qry = _db.activity_kind_detail.AsQueryable();
qry = qry.Where(o => o.activity_kind_num == this_id);
var qry = _db.activity_kind_detail.Where(o => o.activity_kind_num == this_id);
int i = 1;
//已有值
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
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -927,13 +926,12 @@ public class activityController : ApiController
if (kind > 0)
{
int i = 1;
var qry2 = _db.activity_kind_detail.AsQueryable();
qry2 = qry2.Where(o => o.activity_kind_num == kind);
var qry2 = _db.activity_kind_detail.Where(o => o.activity_kind_num == kind);
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
{
list = qry2.Select(x => new
list = qry2List.Select(x => new
{
id = i++,
num = 0,
@@ -1176,18 +1174,15 @@ public class activityController : ApiController
int kind = prod.kind ?? 0; //分類
var qry1 = _db.activity_spares.AsQueryable();
qry1 = qry1.Where(o => o.activity_num == this_act_id);
qry1 = qry1.OrderBy(o => o.num);
var qry1 = _db.activity_spares.Where(o => o.activity_num == this_act_id).OrderBy(o => o.num);
var count = qry1.Count(); //pageSize = count;//一次取回??
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
{
list = qry1.Select(x => new
list = qry1List.Select(x => new
{
id = i++,
num = x.num,
@@ -1331,7 +1326,7 @@ public class activityController : ApiController
string sortBy = "", bool sortDesc = false)
{
var qry = _db.activity_check.AsQueryable();
var qry = _db.activity_check.AsEnumerable();
if (!string.IsNullOrEmpty(q.activityTxt))
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 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
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
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 => (_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);
@@ -1518,10 +1513,10 @@ public class activityController : ApiController
qry = qry.OrderBy(O => O.kind).ThenBy(o => o.num);
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
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
kind = x.kind,

View File

@@ -220,32 +220,32 @@ public class orderController : ApiController
if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim()));
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))
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))
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))
{
//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.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))
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 (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")
{
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"))
{
if (sortDesc)
qry = qry.OrderByDescending(o => o.follower?.u_name);
qry = qry.OrderByDescending(o => o.follower != null ? o.follower.u_name : "");
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"))
{
if (sortDesc)
qry = qry.OrderByDescending(o => o.activity?.subject);
qry = qry.OrderByDescending(o => o.activity != null ? o.activity.subject : "");
else
qry = qry.OrderBy(o => o.activity?.subject);
qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : "");
}
else
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 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();

View File

@@ -199,7 +199,7 @@ public class apporderController : ApiController
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);//品項
@@ -218,32 +218,32 @@ public class apporderController : ApiController
if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim()));
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))
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))
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))
{
//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.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))
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 (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")
{
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");
}
}