Exemple #1
0
        public HttpResponseMessage GetById(HttpRequestMessage request,
                                           [FromBody] OrderViewModel orderViewModel)
        {
            var transactionalInformation = new TransactionalInformation();
            HttpResponseMessage   response;
            List <OrderDetailDTO> orderDetailDTOs;

            var orderId  = orderViewModel.ID;
            var orderDto = _orderBusinessService.GetOrder(orderId, out transactionalInformation, out orderDetailDTOs);


            if (transactionalInformation.ReturnStatus == false)
            {
                orderViewModel.ReturnStatus     = false;
                orderViewModel.ReturnMessage    = transactionalInformation.ReturnMessage;
                orderViewModel.ValidationErrors = transactionalInformation.ValidationErrors;

                var responseError = request.CreateResponse(HttpStatusCode.BadRequest, orderViewModel);
                return(responseError);
            }
            else
            {
                orderViewModel.CopyFromOrderDTO(orderDto);
                orderViewModel.OrderDetailDTOs = orderDetailDTOs;
                orderViewModel.ReturnStatus    = true;
                orderViewModel.ReturnMessage   = transactionalInformation.ReturnMessage;
                response = request.CreateResponse(HttpStatusCode.OK, orderViewModel);
            }

            return(response);
        }