Пример #1
0
        // Helping method used to convert an order from server.domain to client.domain.
        private Order BuildOrderFromServices(OrderReference.Order order, List <Orderline> ol)
        {
            Customer c = new Customer(order.Customer.FirstName, order.Customer.LastName, order.Customer.Phone,
                                      order.Customer.Email, order.Customer.Address, order.Customer.ZipCode, order.Customer.City);

            Order o = new Order(c)
            {
                Orderlines  = ol,
                ID          = order.ID,
                DateCreated = order.DateCreated,
                Total       = order.Total,
            };

            o.ErrorMessage = order.ErrorMessage;
            return(o);
        }
Пример #2
0
        // Helping method used to convert OrderReference.Order to Client.Domain.Order
        // Builds order with orderlines
        private Order BuildClientOrder(OrderReference.Order o)
        {
            List <Orderline> orderlines = new List <Orderline>();

            Customer c = new Customer {
                Email = o.Customer.Email
            };

            foreach (var ol in o.Orderlines)
            {
                Product p = new Product {
                    ID = ol.Product.ID
                };

                Orderline orderline = new Orderline {
                    ID       = ol.ID,
                    Quantity = ol.Quantity,
                    SubTotal = ol.SubTotal,
                    Product  = p
                };

                orderlines.Add(orderline);
            }

            Order order = new Order {
                ID          = o.ID,
                Total       = o.Total,
                DateCreated = o.DateCreated,
                Customer    = c,
                Orderlines  = orderlines
            };

            order.ErrorMessage = o.ErrorMessage;

            return(order);
        }