public HttpResponseMessage CreateOrderLineItem(HttpRequestMessage request, [FromBody] OrderDetailDTO orderDTO)
        {
            OrdersApiModel           ordersWebApiModel = new OrdersApiModel();
            TransactionalInformation transaction       = new TransactionalInformation();
            OrdersBusinessService    ordersBusinessService;

            ordersWebApiModel.IsAuthenicated = true;

            ordersBusinessService = new OrdersBusinessService(ordersDataService);

            OrderDetail orderDetail = ordersBusinessService.CreateOrderDetailLineItem(
                orderDTO.OrderID,
                orderDTO.ProductID,
                orderDTO.Quantity,
                out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }


            List <OrderDetails> orderDetails = ordersBusinessService.GetOrderDetails(orderDTO.OrderID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }


            Order order = ordersBusinessService.GetOrder(orderDTO.OrderID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }

            transaction.ReturnMessage.Add("Detail line item succcessfully added.");

            ordersWebApiModel.ReturnStatus  = transaction.ReturnStatus;
            ordersWebApiModel.ReturnMessage = transaction.ReturnMessage;
            ordersWebApiModel.OrderDetails  = orderDetails;
            ordersWebApiModel.Order         = order;

            var response = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.OK, ordersWebApiModel);

            return(response);
        }
        public HttpResponseMessage GetOrder(HttpRequestMessage request, [FromBody] GetOrderDTO orderDTO)
        {
            OrdersApiModel           ordersWebApiModel = new OrdersApiModel();
            TransactionalInformation transaction       = new TransactionalInformation();
            OrdersBusinessService    ordersBusinessService;
            CustomersBusinessService customersBusinessService;

            ordersWebApiModel.IsAuthenicated = true;

            ordersBusinessService = new OrdersBusinessService(ordersDataService);
            List <Shipper> shippers = ordersBusinessService.GetShippers(out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }

            Order order = ordersBusinessService.GetOrder(orderDTO.OrderID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }

            customersBusinessService = new CustomersBusinessService(customersDataService);
            Customer customer = customersBusinessService.GetCustomer(order.CustomerID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }

            List <OrderDetails> orderDetails = ordersBusinessService.GetOrderDetails(orderDTO.OrderID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage    = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus     = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return(badResponse);
            }

            ordersWebApiModel.ReturnStatus  = transaction.ReturnStatus;
            ordersWebApiModel.ReturnMessage = transaction.ReturnMessage;
            ordersWebApiModel.Customer      = customer;
            ordersWebApiModel.Order         = order;
            ordersWebApiModel.Shippers      = shippers;
            ordersWebApiModel.OrderDetails  = orderDetails;

            var response = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.OK, ordersWebApiModel);

            return(response);
        }