Merge remote-tracking branch 'origin/0.1' into dapper
# Conflicts: # web/App_Code/Model/Model.Designer.cs # web/App_Code/Model/Model.cs # web/App_Code/Model/Model.edmx # web/web.config
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
using System;
|
||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using PagedList;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using PagedList;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Web.Services;
|
||||
using static TreeView;
|
||||
using System.Data.Entity;
|
||||
|
||||
// api/activity
|
||||
//[ezAuthorize(Roles = "admin")]//群組:*
|
||||
@@ -126,6 +130,12 @@ public class activityController : ApiController
|
||||
if (prod != null)
|
||||
{
|
||||
////prod.IsDel = true; ////不確定是否新增欄位? 先註解
|
||||
|
||||
// 先刪除子項目
|
||||
var prod2 = _db.act_bom.Where(q => q.package_num == prod.num).ToList();
|
||||
_db.act_bom.RemoveRange(prod2);
|
||||
|
||||
_db.actItems.Remove(prod);
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
MyWeb.admin admin = new MyWeb.admin();//api裡不可以用MyWeb
|
||||
@@ -190,12 +200,18 @@ public class activityController : ApiController
|
||||
if (prod.Count() > 0)
|
||||
{
|
||||
//var prod2 = _db.actItem_files.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.actItem_num))).ToList();
|
||||
var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList();
|
||||
if (prod2.Count > 0)
|
||||
{
|
||||
_db.actItem_files.RemoveRange(prod2);
|
||||
//_db.SaveChanges();
|
||||
}
|
||||
//var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList();
|
||||
//if (prod2.Count > 0)
|
||||
//{
|
||||
// _db.actItem_files.RemoveRange(prod2);
|
||||
// //_db.SaveChanges();
|
||||
//}
|
||||
|
||||
// 先刪除子項目
|
||||
var parentBoms = _db.act_bom.Where(q => q.item_num.HasValue && ids.Contains(q.item_num.Value)).ToList();
|
||||
var parentIds = parentBoms.Select(x => x.num).ToList(); // 取得母件 id
|
||||
var childBoms = _db.act_bom.Where(q => q.package_num.HasValue && parentIds.Contains(q.package_num.Value)).ToList();
|
||||
_db.act_bom.RemoveRange(childBoms);
|
||||
|
||||
_db.actItems.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
@@ -314,6 +330,36 @@ public class activityController : ApiController
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
public class SortOrderRequest
|
||||
{
|
||||
public List<int> ids { get; set; }
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/activity/SaveItemList")]
|
||||
public IHttpActionResult UpdateSortOrder([FromBody] SortOrderRequest request)
|
||||
{
|
||||
if (request == null || request.ids == null) return BadRequest();
|
||||
|
||||
using (Model.ezEntities _db = new Model.ezEntities())
|
||||
{
|
||||
int totalCount = request.ids.Count;
|
||||
|
||||
for (int i = 0; i < totalCount; i++)
|
||||
{
|
||||
int id = request.ids[i];
|
||||
var item = _db.actItems.FirstOrDefault(x => x.num == id);
|
||||
if (item != null)
|
||||
{
|
||||
// 改成總數減去索引,這樣第一筆 (i=0) 會拿到最大的數字
|
||||
item.sort_order = totalCount - i;
|
||||
}
|
||||
}
|
||||
_db.SaveChanges();
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/activity/GetItemList")]
|
||||
public IHttpActionResult GetItemList([FromBody] Model.ViewModel.actItem q, int page, int pageSize = 10,
|
||||
@@ -418,8 +464,14 @@ public class activityController : ApiController
|
||||
else
|
||||
qry = qry.OrderBy(o => o.status);
|
||||
}
|
||||
else
|
||||
else if (sortBy.Equals("num"))
|
||||
{
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
}
|
||||
else
|
||||
{
|
||||
qry = qry.OrderByDescending(o => o.sort_order);
|
||||
}
|
||||
|
||||
var tdesc = publicFun.enum_desc<Model.activity.category>();
|
||||
var count = qry.Count(); //pageSize = count;//一次取回??
|
||||
@@ -1303,7 +1355,7 @@ public class activityController : ApiController
|
||||
[Route("api/activity/OrderCheckIn")]
|
||||
public IHttpActionResult OrderCheckIn([FromBody] Model.activity_check item)
|
||||
{
|
||||
if (item.f_num.HasValue && item.activity_num.HasValue && item.qty.HasValue && item.status.HasValue)
|
||||
if (item.f_num.HasValue && item.activity_num.HasValue && item.status.HasValue)
|
||||
{
|
||||
//同一天不能簽到兩次以上
|
||||
Model.activity_check check = _db.activity_check
|
||||
|
||||
Reference in New Issue
Block a user