public async Task <IActionResult> Create(Guid?productId, [FromBody] ProductCatalogModel product) { try { if (!productId.HasValue) { productId = Guid.NewGuid(); } var createdVendor = product.Clone(); createdVendor.CreationDate = DateTime.UtcNow; createdVendor.LastUpdate = null; createdVendor.Id = productId.Value; var savedVendor = await repository.Create(createdVendor); return(CreatedAtAction(nameof(Get), new { vendorId = savedVendor.Id }, savedVendor)); } catch (Exception ex) { // TODO: handle error System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; } }
public async Task <IActionResult> Update(Guid productId, [FromBody] ProductCatalogModel product) { try { var updatedProduct = product.Clone(); updatedProduct.Id = productId; updatedProduct.LastUpdate = DateTime.UtcNow; var savedVendor = await this.repository.Update(productId.ToString(), updatedProduct); return(new OkObjectResult(savedVendor)); } catch (Exception ex) { // TODO: handle error System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; } }