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