Exemplo n.º 1
0
        public async Task<ActionResult> Create([Bind(Include = "Id,Date,Time,Duration,Type,MaxAttendance")] SingleClassSetup singleClassSetup)
        {
            Class c = new Class();
            c.MaxAttendance = singleClassSetup.MaxAttendance;
            c.Type = singleClassSetup.Type;
            c.Duration = singleClassSetup.Duration;
            c.Time = ((DateTime)singleClassSetup.Date).Add(singleClassSetup.Time);
            c.Attendance = new List<Athlete>();

            singleClassSetup.GeneratedClass = c;

            ModelState.Remove("GeneratedClass");
            if (ModelState.IsValid)
            {
                db.SingleClasses.Add(singleClassSetup);

                try
                {
                    await db.SaveChangesAsync();
                } catch(DbEntityValidationException e)
                {
                    e.ThrowDetailedEntityValidationErrors();
                }

                return RedirectToAction("Index");
            }

            return View(singleClassSetup);
        }
Exemplo n.º 2
0
        public async void SendClassReminder(string email, Class cls)
        {
            SmtpMessageSender sender = new SmtpMessageSender();
            string subject = String.Format("Don't Forget to Signup for {0}!", cls.Type);
            string greeting = String.Format("<h1>Hey there!</h1>");
            string body = String.Format("<p>You still haven't signed up for your {0} class on {1}!</p>", cls.Type, cls.Time.Value.ToString("MM/dd/yyyy"));
            string link = String.Format(@"<p><a href = ""http://localhost:11700/Classes/Details?Id={0}"">Click here to signup!</a></p>", cls.Id);

            string message = greeting + body + link;

            await sender.SendEmailAsync(email, subject, message);
        }