Пример #1
0
        public OrderDetails FindOrder(long orderId)
        {
            Order        order        = OrderDao.Find(orderId);
            OrderDetails orderDetails = new OrderDetails(order.orderId, order.usrId, CardDao.Find(order.idCard).cardNumber, order.postalAddress, order.orderDate);

            return(orderDetails);
        }
Пример #2
0
        public List <OrderDetails> ViewOrdersByUser(long usrId, int startIndex, int count)
        {
            UserProfile User = UserProfileDao.Find(usrId);

            List <OrderDetails> ordersDetails = new List <OrderDetails>();

            List <Order> orders = User.Orders.ToList();

            int c = 0;

            for (int i = startIndex; i < orders.Count; i++)
            {
                if (c == count)
                {
                    break;
                }
                List <OrderLine> orderLines = orders.ElementAt(i).OrderLines.ToList();

                List <OrderLineDetails> orderLinesDetails = new List <OrderLineDetails>();
                for (int j = 0; j < orderLines.Count; j++)
                {
                    string           productName   = orderLines.ElementAt(j).Product.name;
                    int              numberOfUnits = orderLines.ElementAt(j).numberOfUnits;
                    float            unitPrize     = (float)orderLines.ElementAt(j).unitPrize;
                    OrderLineDetails orderLine     = new OrderLineDetails(orders.ElementAt(i).orderId, productName, numberOfUnits, unitPrize);
                    orderLinesDetails.Add(orderLine);
                }
                long     orderId       = orders.ElementAt(i).orderId;
                string   cardNumber    = CardDao.Find(orders.ElementAt(i).idCard).cardNumber;
                int      postalAddress = orders.ElementAt(i).postalAddress;
                DateTime orderDate     = orders.ElementAt(i).orderDate;
                ordersDetails.Add(new OrderDetails(orderId, usrId, cardNumber, postalAddress, orderDate, orderLinesDetails));
                c++;
            }
            return(ordersDetails);
        }