Пример #1
0
        public async Task <IActionResult> Create([FromBody] CreatePedidoRequest request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState.GetErrorResponse()));
                }

                var response = await _service.Create(request);

                if (!response.Success)
                {
                    return(BadRequest(response.Erros));
                }

                return(Ok(new { CodPedido = response.CodPedido }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex?.InnerException?.Message ?? ex.Message));
            }
        }