Esempio n. 1
0
        public static List <PastOrder> CreateSeveral(List <ProcessingOrder> processingOrders, User user)
        {
            List <PastOrder> pastOrders = new List <PastOrder>();

            foreach (ProcessingOrder processingOrder in processingOrders)
            {
                PastOrder pastOrder = PastOrderFactory.Create(processingOrder, user);
                pastOrders.Add(pastOrder);
            }
            return(pastOrders);
        }
Esempio n. 2
0
        public static PastOrder Create(ProcessingOrder processingOrder, User user)
        {
            PastOrder pastOrder = new PastOrder();

            pastOrder.User           = user;
            pastOrder.Date           = DateTime.Now;
            pastOrder.Amount         = processingOrder.TotalAmount;
            pastOrder.Tour           = processingOrder.Tour;
            pastOrder.AdultNumber    = processingOrder.AdultNumber;
            pastOrder.ChildrenNumber = processingOrder.ChildrenNumber;

            return(pastOrder);
        }
Esempio n. 3
0
        private void Orders(List <User> users, List <Tour> tours)
        {
            List <PastOrder> orders          = new List <PastOrder>();
            Random           randomGenerator = new Random();

            users.ForEach(u =>
            {
                double amount   = Math.Round(randomGenerator.NextDouble() * 50);
                PastOrder order = new PastOrder()
                {
                    Amount = amount,
                    Tour   = tours[randomGenerator.Next(0, tours.Count)],
                    User   = u,
                    Date   = DateTime.Now - TimeSpan.FromDays(randomGenerator.Next(15, 100))
                };
                orders.Add(order);
            });
            _context.AddRange(orders);
        }