예제 #1
0
        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());
            }
        }
예제 #3
0
        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());
            }
        }
예제 #4
0
        public async Task <IActionResult> DeleteProduct(int id)
        {
            await _productService.DeleteProductAsync(id);

            return(NoContent());
        }