public async Task <ApiRequestResult> UpdateAsync(ProductCategoryDto dto) { var entity = await _productCategoryRepository.GetAsync(dto.Id.Value); var newEntity = dto.EntityMap(entity); await _productCategoryRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> AddAsync(ProductCategoryDto dto) { var command = dto.EntityMap <ProductCategoryDto, ProductCategory>(); command.Id = Guid.NewGuid(); await _productCategoryRepository.AddAsync(command); foreach (var item in dto.ProductAttributeIdList) { var productAttrCateR = new ProductCategoryAttributeRelation { ProductCategoryId = command.Id, ProductAttributeId = item, }; await _productCategoryRepository.AddProductCateAttrAsync(productAttrCateR); } return(ApiRequestResult.Success("添加成功")); }