public async Task <IHttpActionResult> UpdateProduct([FromUri] int id, [FromBody] UpdateProductRequest updateRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await _productService.UpdateProductAsync(id, updateRequest); return(this.Ok(result)); } catch (RequestedResourceNotFoundException ex) { return(this.BadRequest(ex.Message)); } catch (RequestedResourceHasConflictException ex) { return(this.ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Conflict, ex.Message))); } catch (Exception) { return(this.InternalServerError()); } }
public async Task <IHttpActionResult> UpdateProductAsync([FromUri] int id, [FromBody] UpdateProductRequest updateRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id < 1) { return(BadRequest($"Argument {nameof(id)} must be greater than zero.")); } try { await _productService.UpdateProductAsync(id, updateRequest); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); } catch (RequestedResourceHasConflictException) { return(Conflict()); } catch (RequestedResourceNotFoundException) { return(NotFound()); } }
public async Task <IHttpActionResult> UpdateProduct([FromUri] int id, [System.Web.Http.FromBody] UpdateProductRequest updateRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _productService.UpdateProductAsync(id, updateRequest); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); }
public async Task <IActionResult> UpdateProduct(int id, [FromBody] UpdateProductRequest updateRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _productService.UpdateProductAsync(id, updateRequest); return(NoContent()); }