Example #1
0
        public ActionResult BagelsHere(string location)
        {
            var bagellerService = new BagellerService();

            var model = new SendBagelsAreHereEmailModel()
            {
                Location = location,
                Bagellers = bagellerService.FetchAll()
            };
            new MailController().SendBagelsAreHereEmail(model).DeliverAsync();

            return View(model);
        }
Example #2
0
        public ActionResult SendDayBeforeReminderEmail()
        {
            var bagellerService = new BagellerService();
            var bagellers = bagellerService.FetchAll();
            var nextBageller = bagellers.First();
            //only send the email if the next purchase date is this week
            if (nextBageller.NextPurchaseDate < DateTime.Today.AddDays(7))
            {
                var model = new DayBeforeReminderEmailModel
                                {
                                    Bageller = nextBageller,
                                    ShoppingList = new ShoppingListModel(BagelShopService.BuildFullShoppingList(bagellers))
                                };
                new MailController().SendDayBeforeReminderEmail(model).DeliverAsync();
            }

            return null;
        }
        public void Execute()
        {
            //System.Diagnostics.Debugger.Launch();
            var bagellers = new BagellerService().FetchAll();
            var emailList = string.Join(",", bagellers.Select(x => x.Email));
            //emailList = "*****@*****.**";
            var nextBageller = bagellers.First();

            var subject = "This Week's Bageller is: " + nextBageller.Name;
            var body = new StringBuilder();
            body.Append("<h1>Upcoming Bagellers:</h1>");
            body.Append("<table border=\"0\">");
            foreach (var bageller in bagellers.Skip(1))
            {
                body.Append("<tr><th style='text-align:left;'>{0}</th><td>{1}</td></tr>"
                                    .FormatWith(bageller.NextPurchaseDate.ToShortDateString(), bageller.Name));
            }
            body.Append("</table>");
            EmailUtil.SendHtmlEmail(emailList, null, "Bagel Club <*****@*****.**>", subject, body.ToString());
        }
Example #4
0
        public ActionResult SendWeekStartReminderEmail()
        {
            var bagellerService = new BagellerService();
            var bagellers = bagellerService.FetchAll();
            var nextBageller = bagellers.First();
            //set the next purchase dates for bagellers who have already made their purchase
            while (nextBageller.NextPurchaseDate.IsBefore(DateTime.Now))
            {
                bagellerService.SetNextPurchaseDate(nextBageller);
                bagellerService.Save(nextBageller);

                bagellers = bagellerService.FetchAll().OrderBy(x => x.NextPurchaseDate);
                nextBageller = bagellers.First();
            }
            new MailController().SendWeekStartReminderEmail(bagellers).DeliverAsync();

            return null;
        }