/// <summary> /// 添加信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public OperationResult AddAttrs(params AttrInputDto[] inputDtos) { OperationResult result = AttrRepository.Insert(inputDtos, dto => { if (CategoryRepository.CheckExists(c => c.Name == dto.Name)) { throw new Exception("分类:{0}已经存在,不能添加".FormatWith(dto.Name)); } }, (dto, entity) => { if (dto.CategoryId.HasValue && dto.CategoryId.Value > 0) { Category category = CategoryRepository.GetByKey(dto.CategoryId.Value); if (category == null) { throw new Exception("发布分类不存在"); } category.Attrs.Add(entity); entity.Category = category; } return(entity); }); return(result); }
/// <summary> /// 添加信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public OperationResult AddGoodsColorSpecificationItems(params GoodsColorSpecificationItemInputDto[] inputDtos) { OperationResult result = GoodsColorSpecificationItemRepository.Insert(inputDtos, dto => { if (CategoryRepository.CheckExists(c => c.Name == dto.Name)) { throw new Exception("颜色:{0}已经存在,不能添加".FormatWith(dto.Name)); } }, (dto, entity) => { return(entity); }); return(result); }
/// <summary> /// 检查信息信息是否存在 /// </summary> /// <param name="predicate">检查谓语表达式</param> /// <param name="id">更新的信息编号</param> /// <returns>信息是否存在</returns> public bool CheckCategoryExists(Expression <Func <Category, bool> > predicate, int id = 0) { return(CategoryRepository.CheckExists(predicate, id)); }