文件名从 Yw.Service.Unit.Core/5-service/3-value/SysUnitValue.cs 修改 |
| | |
| | | private static void UpdateCache(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var dal = new DAL.SysUnitValue(); |
| | | var entityList = dal.GetByIds(Ids); |
| | | var modelList = Entity2Models(entityList); |
| | |
| | | public List<Model.SysUnitValue> GetByIds(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | var list = all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.SortCode).ToList(); |
| | | return list; |
| | |
| | | { |
| | | var type = new SysUnitType().GetByCode(Code); |
| | | if (type == null) |
| | | { |
| | | return default; |
| | | } |
| | | return GetByTypeID(type.ID); |
| | | } |
| | | |
| | |
| | | { |
| | | var type = new Service.SysUnitType().GetByCode(TypeCode); |
| | | if (type == null) |
| | | { |
| | | return default; |
| | | } |
| | | return GetByCode(type.ID, Code); |
| | | } |
| | | |
| | |
| | | public int GetMaxSortCodeByTypeID(long TypeID) |
| | | { |
| | | var all = GetByTypeID(TypeID); |
| | | if (all.Count < 1) |
| | | if (all == null || all.Count < 1) |
| | | { |
| | | return 0; |
| | | } |
| | | return all.Max(x => x.SortCode); |
| | | } |
| | | |
| | |
| | | public long Insert(Model.SysUnitValue model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = new DAL.SysUnitValue(); |
| | | var id = dal.Insert(entity); |
| | |
| | | public bool Inserts(List<Model.SysUnitValue> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = new DAL.SysUnitValue(); |
| | | var entityList = Model2Entities(list); |
| | | var ids = dal.InsertsR(entityList); |
| | |
| | | public bool Update(Model.SysUnitValue model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = new DAL.SysUnitValue(); |
| | | var bol = dal.Update(entity); |
| | |
| | | public bool Updates(List<Model.SysUnitValue> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var entityList = Model2Entities(list.ToList()); |
| | | var dal = new DAL.SysUnitValue(); |
| | | var bol = dal.Updates(entityList); |
| | |
| | | public bool UpdateSortCode(long ID, int SortCode) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = new DAL.SysUnitValue(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | |
| | | public bool UpdateSorter(List<Model.Sorter> sorters) |
| | | { |
| | | if (sorters == null || !sorters.Any()) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = new DAL.SysUnitValue(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | |
| | | public bool IsExistCode(long TypeID, string Code) |
| | | { |
| | | if (string.IsNullOrEmpty(Code)) |
| | | { |
| | | return false; |
| | | } |
| | | var all = GetAll(); |
| | | if (all == null || all.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | return all.Exists(x => x.TypeID == TypeID && x.Code == Code); |
| | | } |
| | |
| | | public bool IsExistCodeExceptID(long TypeID, string Code, long ExceptID) |
| | | { |
| | | if (string.IsNullOrEmpty(Code)) |
| | | { |
| | | return false; |
| | | } |
| | | var all = GetAll(); |
| | | if (all == null || all.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | return all.Exists(x => x.TypeID == TypeID && x.Code == Code && x.ID != ExceptID); |
| | | } |
| | | |