public override async Task <ProductDto> Update(Product entity, string id) { try { if (entity.id != id) { throw new BusinessException("id must be the same in request and payload"); } return(await Task.Run(() => { ProductManagementService.UpdateProduct(id, entity); if (ProductManagementService.HasErrors()) { throw new BusinessException(ProductManagementService.ServiceErrorMessage()); } return WrapItem(entity); })); } catch (NotFoundException ex) { throw new BusinessException("Error retrieving item", ex); } catch (Exception ex) { throw new InternalException("Error retrieving item", ex); } }
public override async Task <ProductDto> Create(Product entity) { try { return(await Task.Run(() => { ProductManagementService.CreateProduct(entity); if (ProductManagementService.HasErrors()) { throw new BusinessException(ProductManagementService.ServiceErrorMessage()); } return WrapItem(entity); })); } catch (Exception ex) { throw new InternalException("Error retrieving item", ex); } }