Ejemplo n.º 1
0
        public async Task <IHttpActionResult> GetByCustomer(GetOrderByCustomerModelIn modelIn)
        {
            try
            {
                if (modelIn.IsNull())
                {
                    return(BadRequest(new ApiMessageResponse <IEnumerable <GetOrderModelOut> >("Modelo Inválido")));
                }

                if (!ModelState.IsValid)
                {
                    var errors = ModelState.GetModelErrors();
                    return(BadRequest(new ApiMessageResponse <IEnumerable <GetOrderModelOut> >(ModelState.StringifyModelErrors())));
                }

                OrderService _orderService = new OrderService();


                return(Ok(new ApiMessageResponse <IEnumerable <GetOrderModelOut> >(await _orderService.GetByCustomerAsync(modelIn))));
            }
            catch (Exception ex)
            {
                return(BadRequest(new ApiMessageResponse <IEnumerable <GetOrderModelOut> >(ex.GetFirstException().Message)));
            }
        }