修復 Batch 1: FollowerController, memberController, accountingController, stockController
- FollowerController.cs: 8 處修復 - memberController.cs: 9 處修復 - accountingController.cs: 8 處修復 - stockController.cs: 8 處修復 總計 33 處,覆蓋會員、財務、庫存核心功能
This commit is contained in:
@@ -54,7 +54,7 @@ public class stockController : BaseApiController
|
||||
// DELETE api/<controller>/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
var prod = _db.stocks.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
|
||||
var prod = _db.stocks.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
var prod2 = prod.stock_files;
|
||||
@@ -86,10 +86,10 @@ public class stockController : BaseApiController
|
||||
if (!string.IsNullOrEmpty(nums))
|
||||
{
|
||||
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
|
||||
var prod = _db.stocks.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
|
||||
var prod = _db.stocks.Where(q => getDelItem.Contains(q.num)).ToList();
|
||||
if (prod.Count() > 0)
|
||||
{
|
||||
var prod2 = _db.stock_files.AsEnumerable().Where(q => q.stock_num.HasValue && getDelItem.Contains(q.stock_num.Value)).ToList();
|
||||
var prod2 = _db.stock_files.Where(q => q.stock_num.HasValue && getDelItem.Contains(q.stock_num.Value)).ToList();
|
||||
if (prod2.Count() > 0)
|
||||
{
|
||||
publicFun publicFun = new publicFun();
|
||||
@@ -114,7 +114,7 @@ public class stockController : BaseApiController
|
||||
public IHttpActionResult GetList([FromBody] Model.ViewModel.stock q, int page, int pageSize = 10,
|
||||
string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.stocks.AsEnumerable();
|
||||
var qry = _db.stocks.AsQueryable();
|
||||
|
||||
if (q.category.HasValue)
|
||||
qry = qry.Where(o => o.category == q.category.Value);
|
||||
@@ -198,10 +198,12 @@ public class stockController : BaseApiController
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
|
||||
var tdesc = publicFun.enum_desc<Model.stock.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,
|
||||
@@ -230,7 +232,7 @@ public class stockController : BaseApiController
|
||||
price = x.price,
|
||||
|
||||
}),
|
||||
count = qry.Count()
|
||||
count = count
|
||||
|
||||
};
|
||||
|
||||
@@ -244,7 +246,7 @@ public class stockController : BaseApiController
|
||||
public IHttpActionResult GetKindList([FromBody] Model.ViewModel.stock_kind q, int page, int pageSize = 10,
|
||||
string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.stock_kind.AsEnumerable();
|
||||
var qry = _db.stock_kind.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(q.kind))
|
||||
qry = qry.Where(o => o.kind.Contains(q.kind));
|
||||
@@ -293,7 +295,7 @@ public class stockController : BaseApiController
|
||||
public IHttpActionResult GetReasonList([FromBody] Model.ViewModel.stock_reason q, int page, int pageSize = 10,
|
||||
string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.stock_reason.AsEnumerable();
|
||||
var qry = _db.stock_reason.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(q.kind))
|
||||
qry = qry.Where(o => o.kind.Contains(q.kind));
|
||||
@@ -335,15 +337,16 @@ public class stockController : BaseApiController
|
||||
if (q.stock_num.HasValue && q.stock_num.Value>0)
|
||||
{
|
||||
//檢查
|
||||
var qry = _db.stock_files.AsEnumerable();
|
||||
qry = qry.Where(o => o.stock_num == q.stock_num.Value);
|
||||
qry.OrderByDescending(x => x.num);
|
||||
var qry = _db.stock_files.Where(o => o.stock_num == q.stock_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,
|
||||
@@ -351,7 +354,7 @@ public class stockController : BaseApiController
|
||||
pic1 = x.pic1,
|
||||
pic1_name = x.pic1_name,
|
||||
}),
|
||||
count = qry.Count(),
|
||||
count = count,
|
||||
};
|
||||
|
||||
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
@@ -466,7 +469,7 @@ public class stockController : BaseApiController
|
||||
[Route("api/stock/DeleteFilesItem/{id}")]//刪除相關檔案
|
||||
public void DeleteFilesItem(int id)
|
||||
{
|
||||
var prod = _db.stock_files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
|
||||
var prod = _db.stock_files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(prod.pic1))
|
||||
|
||||
Reference in New Issue
Block a user