Esempio n. 1
0
 private static void MarkSent(UserRequest ur, int discount)
 {
     UserRequest newR = new UserRequest();
     newR.email = ur.email;
     newR.product = ur.product;
     newR.sent = true;
     newR.lastDiscount = discount;
     ur.sent = true;
     ur.lastDiscount = discount;
     requests.Remove(ur);
     requests.Add(newR);
 }
Esempio n. 2
0
        private static void NewRequest()
        {
            Console.WriteLine("Please select a product");
            string product = Console.ReadLine();

            Console.WriteLine("Please write your email address");
            string email = Console.ReadLine();

            UserRequest newRequest = new UserRequest();
            newRequest.email = email;
            newRequest.product = product;
            requests.Add(newRequest);

            Console.WriteLine("\r\nProduct " + product + " added to our list");
            Console.WriteLine("\r\n\r\n---------------\r\n\r\n");
        }
Esempio n. 3
0
        private static void CheckDiscount(List<Product> products, UserRequest ur)
        {
            foreach (Product p in products)
            {
                int discount = int.Parse(p.percentOff.TrimEnd(new char[] { '%', ' ' }));

                /*
                 Conditions:
                 (Discount > 20 and email not sent yet)
                 or
                 (Discount > 20 and email sent but new discount > old discount)
                */
                if ((discount > 20) && ((!ur.sent || (ur.sent && ur.lastDiscount < discount))))
                {
                    SendEmail(ur.email, p.productName, discount);
                    MarkSent(ur, discount);
                }
            }
        }