Example #1
0
        /// <summary>
        /// Translates Order into OrderBE.
        /// </summary>
        /// <param name="order"> order data entity.</param>
        /// <returns></returns>
        public OrderBE Translate(Order order)
        {
            if (order != null)
            {
                OrderBE orderBE = new OrderBE()
                {
                    OrderId       = order.OrderId,
                    CreateTime    = order.CreatedDate,
                    CustomerId    = order.CustomerId,
                    OrderStatusId = order.StatusId,
                    Customer      = new CustomerBE(),
                    OrderStatus   = new OrderStatusBE()
                };

                if (order.Customer != null)
                {
                    CustomerTranslator customerTranslator = new CustomerTranslator();
                    orderBE.Customer = customerTranslator.Translate(order.Customer);
                }
                if (order.OrderStatus != null)
                {
                    orderBE.OrderStatus.OrderStatusId = order.OrderStatus.StatusId;
                    orderBE.OrderStatus.StatusName    = order.OrderStatus.StatusName;
                    if (order.StatusId == 1)
                    {
                        orderBE.OrderCheckBoxFlag = true;
                    }
                }
                return(orderBE);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// Get all customers
        /// </summary>
        /// <returns>all the customers in a list</returns>
        public List <CustomerBE> GetAllCustomers()
        {
            TTAEntityContainer DBEntity       = new TTAEntityContainer();
            List <Customer>    listCustomerDE = (from Customer customer in DBEntity.Customers select customer).ToList <Customer>();
            List <CustomerBE>  listCustomerBE = new List <CustomerBE>();

            foreach (Customer customerDE in listCustomerDE)
            {
                CustomerBE customerBE = new CustomerTranslator().Translate(customerDE);
                listCustomerBE.Add(customerBE);
            }
            return(listCustomerBE);
        }