/// <summary> /// 批量删除产品类型 /// </summary> /// <param name="list"></param> /// <returns></returns> public int DelBat(List<string> list) { using (TransactionScope ts = new TransactionScope()) { int line = 0; foreach (string cateNum in list) { ProductCategoryEntity entity = new ProductCategoryEntity(); entity.Where(a => a.CateNum == cateNum); entity.IsDelete = (int)EIsDelete.Deleted; entity.IncludeIsDelete(true); line += this.ProductCategory.Update(entity); } ts.Complete(); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE); } return line; } }
/// <summary> /// 查询所有的产品类别 /// </summary> /// <returns></returns> public List<ProductCategoryEntity> GetList() { List<ProductCategoryEntity> list = CacheHelper.Get(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE) as List<ProductCategoryEntity>; if (!list.IsNullOrEmpty()) { return list; } ProductCategoryEntity entity = new ProductCategoryEntity(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); list = this.ProductCategory.GetList(entity); if (!list.IsNullOrEmpty()) { CacheHelper.Insert(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, list); } return list; }
/// <summary> /// 查询产品类别分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List<ProductCategoryEntity> GetList(ProductCategoryEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List<ProductCategoryEntity> list = this.ProductCategory.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; if (!list.IsNullOrEmpty()) { AdminProvider adminProvider = new AdminProvider(); foreach (ProductCategoryEntity item in list) { if (!item.CreateUser.IsEmpty()) { AdminEntity admin = adminProvider.GetAdmin(item.CreateUser); item.CreateUser = admin.IsNotNull() ? admin.UserName : item.CreateUser; } } } return list; }
/// <summary> /// 根据产品类别删除删除 /// </summary> /// <param name="cateNum"></param> /// <returns></returns> public int Delete(string cateNum) { ProductCategoryEntity entity = new ProductCategoryEntity(); entity.Where(a => a.CateNum == cateNum); entity.IsDelete = (int)EIsDelete.Deleted; entity.IncludeIsDelete(true); int line = this.ProductCategory.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE); } return line; }