Example #1
0
 // Not implemented. No orders are taken.
 public OrderResponse SetOrders(OrderRequest request)
 {
     return new OrderResponse();
 }
Example #2
0
        /// <summary>
        /// Request order data.
        /// </summary>
        /// <param name="request">Order request message.</param>
        /// <returns>Order response message.</returns>
        public OrderResponse GetOrders(OrderRequest request)
        {
            OrderResponse response = new OrderResponse();
            response.CorrelationId = request.RequestId;

            // Validate client tag, access token, and user credentials
            if (!ValidRequest(request, response, Validate.All))
                return response;

            OrderCriteria criteria = request.Criteria as OrderCriteria;

            if (request.LoadOptions.Contains("Order"))
            {
                Order order = orderDao.GetOrder(criteria.OrderId);

                if (request.LoadOptions.Contains("Customer"))
                    order.Customer = customerDao.GetCustomerByOrder(order.OrderId);

                if (request.LoadOptions.Contains("OrderDetails"))
                    order.OrderDetails = orderDao.GetOrderDetails(order.OrderId);

                response.Order = Mapper.ToDataTransferObject(order);
            }

            if (request.LoadOptions.Contains("Orders"))
            {
                Customer customer = customerDao.GetCustomer(criteria.CustomerId);

                IList<Order> orders = orderDao.GetOrders(customer.CustomerId);
                if (request.LoadOptions.Contains("OrderDetails"))
                {
                    foreach (Order order in orders)
                        order.OrderDetails = orderDao.GetOrderDetails(order.OrderId);
                }

                response.Orders = Mapper.ToDataTransferObjects(orders);
            }

            return response;
        }