public static void Seed() { var activityRespository = new ActivityRepository(); var activity = activityRespository.GetActive(); if (activity != null) return; var seed = new Activity { Name = "Sinterklaasfeest bij Achmea op 28 november 2015", OrganizerEmail = "*****@*****.**", OrganizerName = "Sinterklaas", Active = true, EndDate = DateTime.Parse("2015-11-05 16:00:00.000"), Meetings = new List<Meeting>() { new Meeting { Location = "Midi, Heuvelring 108, Tilburg", DateStart = DateTime.Parse("2015-11-28 10:00:00.000"), DateEnd = DateTime.Parse("2015-11-28 13:00:00.000"), MaxAttendeesCount = 100, Description = "Sessie 1 voor leden: inloop 9.30, start musical 10.00" }, new Meeting { Location = "Midi, Heuvelring 108, Tilburg", DateStart = DateTime.Parse("2015-11-28 10:00:00.000"), DateEnd = DateTime.Parse("2015-11-28 13:00:00.000"), MaxAttendeesCount = 275, Description = "Sessie 1 voor niet-leden: inloop 9.30, start musical 10.00" }, new Meeting { Location = "Midi, Heuvelring 108, Tilburg", DateStart = DateTime.Parse("2015-11-28 12:30:00.000"), DateEnd = DateTime.Parse("2015-11-28 15:30:00.000"), MaxAttendeesCount = 100, Description = "Sessie 2 voor leden: inloop 12.00, start musical 12.30" }, new Meeting { Location = "Midi, Heuvelring 108, Tilburg", DateStart = DateTime.Parse("2015-11-28 12:30:00.000"), DateEnd = DateTime.Parse("2015-11-28 15:30:00.000"), MaxAttendeesCount = 275, Description = "Sessie 2 voor niet-leden: inloop 12.00, start musical 12.30" } } }; using (var transaction = Session.BeginTransaction()) { Session.Save(seed); transaction.Commit(); } }
public CsvActionResult Export(string secret) { if (IsInvalidSecret(secret)) return new CsvActionResult(new DataTable()); var activityRepository = new ActivityRepository(); var activity = activityRepository.GetActive(); var dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Activteit")); dataTable.Columns.Add(new DataColumn("Sessie naam")); dataTable.Columns.Add(new DataColumn("Medewerker e-mail")); dataTable.Columns.Add(new DataColumn("Medewerker voornaam")); dataTable.Columns.Add(new DataColumn("Medewerker achternaam")); dataTable.Columns.Add(new DataColumn("Kind geslacht")); dataTable.Columns.Add(new DataColumn("Kind voornaam")); dataTable.Columns.Add(new DataColumn("Kind achternaam")); dataTable.Columns.Add(new DataColumn("Kind leeftijd")); foreach (var meeting in activity.Meetings) { foreach (var attendee in meeting.Attendees) { foreach (var child in attendee.Children) { var row = dataTable.NewRow(); row["Activteit"] = activity.Name; row["Sessie naam"] = meeting.Description; row["Medewerker e-mail"] = (attendee.Account != null) ? attendee.Account.Email : string.Empty; row["Medewerker voornaam"] = attendee.Firstname; row["Medewerker achternaam"] = attendee.Lastname; row["Kind geslacht"] = child.Gender == Gender.Male ? "Jongen" : "Meisje"; row["Kind voornaam"] = child.Firstname; row["Kind achternaam"] = child.Lastname; row["Kind leeftijd"] = child.Age; dataTable.Rows.Add(row); } } } return new CsvActionResult(dataTable); }
private MailMessage GetMailMessage(Account account) { var activityRepository = new ActivityRepository(); var activity = activityRepository.GetActive(); var body = new StringBuilder(); var request = System.Web.HttpContext.Current.Request; body.Append("<html><body>"); body.AppendFormat("<p><strong>Via deze link kun je je aanmelden voor {0}</strong></p>", activity.Name); body.AppendFormat("<p><a href=\"{0}://{1}/Account/Verify/{2}/{3}\">Klik hier om verder te gaan met je aanmelding</a>.</p>", request.Url.Scheme, // http or https request.Headers["host"], // Server / domain name account.Id, GenerateToken(string.Concat(account.Id.ToString(), account.Email), hmacSymetricKey)); body.AppendFormat("</body></html>"); #if DEBUG body.Append("<br /> <br />"); body.AppendFormat("{0}://{1}/Account/Verify/{2}/{3}", request.Url.Scheme, // http or https request.Headers["host"], // Server / domain name account.Id, GenerateToken(string.Concat(account.Id.ToString(), account.Email), hmacSymetricKey)); #endif return new MailMessage(new MailAddress(activity.OrganizerEmail, activity.OrganizerName), new MailAddress(account.Email)) { IsBodyHtml = true, Body = body.ToString(), Subject = "Uw inschrijving voor het Achmea Sinterklaasfeest" }; }
public ActionResult Verify(string id, string token) { var accountRepository = new AccountRepository(); var account = accountRepository.GetById(id); if (account != null) { if (ValidateToken(string.Concat(account.Id, account.Email), hmacSymetricKey, token)) { // Get the current activity var activityRepository = new ActivityRepository(); var activity = activityRepository.GetActive(); if (activity.HasExpired()) { return RedirectToAction("Expired", "Activity", new { activityId = activity.Id }); } // Set auth cookie FormsAuthentication.SetAuthCookie(account.Email, false); // Set the account as verified account.Verified = true; // Store the account again in the database accountRepository.Save(account); // Now redirect to the Attend page on the Activity controller, passing the account variable return RedirectToAction("Attend", "Activity", new { activityId = activity.Id, accountId = account.Id }); } else { return View("Expired", Mapper.Map(account, new AccountViewModel()) ); } } throw new InvalidOperationException(string.Format("Account niet gevonden. {0}, token {1}", id, token)); }