Exemplo n.º 1
0
        public async Task <IActionResult> Put(string id, [FromBody] OrderEditCommand command)
        {
            try
            {
                await service.EditAsync
                (
                    id,
                    command,
                    ArticleController.GetPathTemplate(Request)
                );

                return(NoContent());
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (DuplicateWaitObjectException ex)
            {
                return(Conflict(ex.Message));
            }
            catch (HttpRequestException ex)
            {
                return(StatusCode(StatusCodes.Status503ServiceUnavailable, ex.Message));
                //return BadRequest(ex.Message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.ToString());
                return(BadRequest(Error));
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Customers(string id, int pageIndex = 1, int pageSize = 100)
 {
     try
     {
         return(Ok
                (
                    await service.GetOrdersByCustomerAsync
                    (
                        id,
                        ArticleController.GetPathTemplate(Request),
                        pageIndex,
                        pageSize
                    )
                ));
     }
     catch (HttpRequestException ex)
     {
         return(StatusCode(StatusCodes.Status503ServiceUnavailable, ex.Message));
         //return BadRequest(ex.Message);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Print(ex.ToString());
         return(BadRequest(Error));
     }
 }
Exemplo n.º 3
0
 public async Task <IActionResult> Post([FromBody] OrderAddCommand command)
 {
     try
     {
         return(Ok
                (
                    await service.AddAsync(command, ArticleController.GetPathTemplate(Request))
                ));
     }
     catch (DuplicateWaitObjectException ex)
     {
         return(Conflict(ex.Message));
     }
     catch (HttpRequestException ex)
     {
         return(StatusCode(StatusCodes.Status503ServiceUnavailable, ex.Message));
         //return BadRequest(ex.Message);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Print(ex.ToString());
         return(BadRequest(Error));
     }
 }