public async Task <IHttpActionResult> DeleteProduct([FromUri] int id) { await _productService.SetStatusAsync(id, true); await _productService.DeleteProductAsync(id); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); }
public async Task <IHttpActionResult> DeleteProduct([FromUri] int id) { try { await _productService.DeleteProductAsync(id); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); } 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> DeleteProductAsync([FromUri] int id) { if (id < 1) { return(BadRequest($"Argument {nameof(id)} must be greater than zero.")); } try { await _productService.DeleteProductAsync(id); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); } catch (RequestedResourceHasConflictException) { return(Conflict()); } catch (RequestedResourceNotFoundException) { return(NotFound()); } }
public async Task <IActionResult> DeleteProduct(int id) { await _productService.DeleteProductAsync(id); return(NoContent()); }