修復 Batch 1: FollowerController, memberController, accountingController, stockController

- FollowerController.cs: 8 處修復
- memberController.cs: 9 處修復
- accountingController.cs: 8 處修復
- stockController.cs: 8 處修復

總計 33 處,覆蓋會員、財務、庫存核心功能
This commit is contained in:
2025-11-12 16:37:59 +08:00
parent cd05ad2305
commit 79b7dd114f
5 changed files with 68 additions and 54 deletions

View File

@@ -52,7 +52,7 @@ public class accountingController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.accountings.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.accountings.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
var prod2 = prod.accounting_files;
@@ -91,10 +91,10 @@ public class accountingController : BaseApiController
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.accountings.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var prod = _db.accountings.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.accounting_files.AsEnumerable().Where(q => q.accounting_num.HasValue && getDelItem.Contains(q.accounting_num.Value)).ToList();
var prod2 = _db.accounting_files.Where(q => q.accounting_num.HasValue && getDelItem.Contains(q.accounting_num.Value)).ToList();
if (prod2.Count() > 0)
{
publicFun publicFun = new publicFun();
@@ -126,7 +126,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.accounting q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accountings.AsEnumerable();
var qry = _db.accountings.AsQueryable();
if (q.category.HasValue)
qry = qry.Where(o => o.category == q.category.Value);
@@ -215,10 +215,12 @@ public class accountingController : BaseApiController
qry = qry.OrderByDescending(o => o.num);
var tdesc = publicFun.enum_desc<Model.accounting.type>();
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
{
num = x.num,
category = x.category,
@@ -245,7 +247,7 @@ public class accountingController : BaseApiController
total =(x.price ?? 0)+( x.tax?? 0),
}),
count = qry.Count()
count = count
};
@@ -259,7 +261,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetTitleKindList([FromBody] Model.ViewModel.accounting_kind q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accounting_kind.AsEnumerable();
var qry = _db.accounting_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -297,7 +299,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetAccountKindList([FromBody] Model.ViewModel.accounting_kind2 q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accounting_kind2.AsEnumerable();
var qry = _db.accounting_kind2.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -341,15 +343,16 @@ public class accountingController : BaseApiController
if (q.accounting_num.HasValue && q.accounting_num.Value > 0)
{
//檢查
var qry = _db.accounting_files.AsEnumerable();
qry = qry.Where(o => o.accounting_num == q.accounting_num.Value);
qry.OrderByDescending(x => x.num);
var qry = _db.accounting_files.Where(o => o.accounting_num == q.accounting_num.Value);
qry = qry.OrderByDescending(x => x.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
int i = 1;
//已有值
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -357,7 +360,7 @@ public class accountingController : BaseApiController
pic1 = x.pic1,
pic1_name = x.pic1_name,
}),
count = qry.Count(),
count = count,
};
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
@@ -473,7 +476,7 @@ public class accountingController : BaseApiController
[Route("api/accounting/DeleteFilesItem/{id}")]//刪除相關檔案
public void DeleteFilesItem(int id)
{
var prod = _db.accounting_files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.accounting_files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
if (!string.IsNullOrEmpty(prod.pic1))