public ResultDTO AddExt(Jinher.AMP.BTP.Deploy.CategoryInnerBrandDTO model) { try { var categoryInnerBrand = CategoryInnerBrand.CreateCategoryInnerBrand(); categoryInnerBrand.BrandId = model.BrandId; categoryInnerBrand.Brandname = model.Brandname; categoryInnerBrand.CategoryId = model.CategoryId; categoryInnerBrand.CategoryName = model.CategoryName; categoryInnerBrand.SubId = model.SubId; categoryInnerBrand.SubName = model.SubName; categoryInnerBrand.SubTime = DateTime.Now; categoryInnerBrand.EntityState = System.Data.EntityState.Added; ContextSession contextSession = ContextFactory.CurrentThreadContext; contextSession.SaveObject(categoryInnerBrand); contextSession.SaveChanges(); return(new ResultDTO { ResultCode = 0, Message = "", isSuccess = true }); } catch (Exception ex) { LogHelper.Error(string.Format("添加添加品牌分类关系发生错误。参数:{0}", JsonHelper.JsonSerializer(model)), ex); return(new ResultDTO { ResultCode = 1, Message = "Error", isSuccess = false }); } }
/// <summary> /// 添加多个分类品牌 /// </summary> /// <param name="models"></param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO AddListExt(System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CategoryInnerBrandDTO> models) { ResultDTO dto = null; try { foreach (var model in models) { var item = CategoryInnerBrand.CreateCategoryInnerBrand(); item.BrandId = model.BrandId; item.Brandname = model.Brandname; item.CategoryId = model.CategoryId; item.CategoryName = model.CategoryName; item.SubTime = model.SubTime; item.ModifiedOn = model.ModifiedOn; item.EntityState = EntityState.Added; ContextFactory.CurrentThreadContext.SaveObject(item); } ContextFactory.CurrentThreadContext.SaveChanges(); dto = new ResultDTO() { ResultCode = 0, Message = "添加分类品牌成功", isSuccess = true }; } catch (Exception ex) { dto = new ResultDTO() { ResultCode = 1, Message = ex.Message, isSuccess = false }; } return(dto); }