Esempio n. 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> SetStatus([FromUri] int id, [FromUri] bool deletedStatus)
        {
            try
            {
                await _productService.SetStatusAsync(id, deletedStatus);

                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent)));
            }
            catch (RequestedResourceNotFoundException ex)
            {
                return(this.BadRequest(ex.Message));
            }
            catch (Exception)
            {
                return(this.InternalServerError());
            }
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> SetStatusAsync([FromUri] int id, [FromUri] bool deletedStatus)
        {
            if (id < 1)
            {
                return(BadRequest($"Argument {nameof(id)} must be greater than zero."));
            }

            try
            {
                await _productService.SetStatusAsync(id, deletedStatus);

                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent)));
            }
            catch (RequestedResourceNotFoundException)
            {
                return(NotFound());
            }
        }
        public async Task <IHttpActionResult> SetStatus([FromUri] int id, [FromUri] bool deletedStatus)
        {
            await _productService.SetStatusAsync(id, deletedStatus);

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent)));
        }
Esempio n. 5
0
        public async Task <IActionResult> SetStatus(int id, bool deletedStatus)
        {
            await _productService.SetStatusAsync(id, deletedStatus);

            return(NoContent());
        }