public IHttpActionResult Put(EditProductCandidate value) { return(this.Ok(new { result = this.ProductService.Update(value) })); }
public Product Update(EditProductCandidate candidate) { Guard.ArgumentIsNull(candidate, "candidate"); Guard.ArgumentIsEmpty(candidate.Name, "name"); Guard.ArgumentIsEmpty(candidate.SKU, "sku"); return(this.SaveAndUpdate(candidate)); }
private Product SaveAndUpdate(EditProductCandidate candidate) { var existing = this.ProductRepository.GetById(candidate.Id); if (existing == null) { throw new ProductDoesNotExistsException(); } if (existing.Environment != this.UserContext.Environment) { throw new ProductDoesNotExistsException(); } existing.Name = candidate.Name; existing.SKU = candidate.SKU; this.Save(); return(existing); }
public ProductDto Update(EditProductCandidate candidate) { return(this.ProductManager.Update(candidate).ToProductDto()); }