using IStation.Untity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Service { /// /// 泵站 /// public partial class ProductInspectionContentValue { #region Query /// /// 通过 ItemID 获取:管理端用,不走缓存 /// public List GetByItemID( long ItemID) { var dal = new DAL.ProductInspectionContentValue(); var all = dal.GetByItemID(ItemID); if(all == null || all.Count == 0) return null; var all2 = Entity2Models(all); return all2.OrderBy(x => x.SortCode).ToList(); } /// /// 通过 ItemID 获取:管理端用,不走缓存 /// public List GetByCorpID(long CorpID) { var dal = new DAL.ProductInspectionContentValue(); var all = dal.GetByCorpID(CorpID); if (all == null || all.Count == 0) return null; var all2 = Entity2Models(all); return all2.OrderBy(x => x.SortCode).ToList(); } #endregion #region Insert /// /// 插入一条数据 /// public long Insert(long CorpID, Model.ProductInspectionContentValue model) { if (model == null) return default; if (model.ItemID < 1) return default; var dal = new DAL.ProductInspectionContentValue(); var entity = Model2Entity(model); entity.CreateTime = DateTime.Now; var id = dal.Insert(entity); if (id > 0) { IStation.Service.InspectionContentBundleCacheHelper.Remove (CorpID); } return id; } /// /// 插入多条 /// public bool Inserts(long CorpID, List list) { if (list == null || list.Count() < 1) return default; var dal = new DAL.ProductInspectionContentValue(); var entity_list = Model2Entities(list.ToList()); foreach(var entity in entity_list) entity.CreateTime = DateTime.Now; var ids = dal.InsertsR(entity_list); if (ids != null && ids.Count > 0) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); return true; } return false; } #endregion #region Update /// /// 更新一条 /// public bool Update(long CorpID, Model.ProductInspectionContentValue model) { if (model == null) return default; if (CorpID < 1) return default; if (model.ID < 1) return default; var dal = new DAL.ProductInspectionContentValue(); var entity = Model2Entity(model); entity.UpdateTime = DateTime.Now; var bol = dal.Update(entity); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); } return bol; } /// /// 更新多条 /// public bool Updates(long CorpID, List list) { if (list == null || list.Count() < 1) return default; if (CorpID < 1) return default; if (list.ToList().Exists(x => x.ID < 1)) return default; var dal = new DAL.ProductInspectionContentValue(); var entity_list = Model2Entities(list.ToList()); foreach (var entity in entity_list) entity.UpdateTime = DateTime.Now; var bol = dal.Updates(entity_list); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); } return bol; } /// /// 更新使用状态 /// public bool UpdateUseStatus(long CorpID, long ID, Model.eUseStatus UseStatus, long UpdateUserID ) { var dal = new DAL.ProductInspectionContentValue(); var bol = dal.UpdateUseStatus(ID, (int)UseStatus, UpdateUserID, DateTime.Now); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); } return bol; } /// /// 更新排序码 /// public bool UpdateSortCode(long CorpID, long ID, int SortCode, long UpdateUserID ) { var dal = new DAL.ProductInspectionContentValue(); var bol = dal.UpdateSortCode(CorpID, ID, SortCode, UpdateUserID, DateTime.Now); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); } return bol; } /// /// 更新排序 /// public bool UpdateSorter(long CorpID, List sorters) { if (sorters == null || sorters.Count() < 1) return default; var dal = new DAL.ProductInspectionContentValue(); var bol = dal.UpdateSorter(CorpID, sorters.ToEntityList()); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID ); } return bol; } #endregion #region Delete /// /// 通过 ID 删除 /// public bool DeleteByID(long CorpID, long ID, out string Msg) { Msg = string.Empty; var dal = new DAL.ProductInspectionContentValue(); var bol = dal.DeleteByID(ID); if (bol) { IStation.Service.InspectionContentBundleCacheHelper.Remove(CorpID); } return bol; } #endregion } }