public ActionResult Register(ChildRegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Admin admin = MVCExtensions.getCurrentAdmin();
                User child = new User();
                child.Createddate = DateTime.UtcNow;
                child.DateOfBirth = model.DateOfBirth;
                child.Email = model.Email.Trim();
                child.Firstname = model.Firstname.Trim();
                child.Surname = model.Surname.Trim();
                child.Gender = model.Gender;
                child.AdminEnrolledID = admin.ID;
                Adapter.UserRepository.Insert(child);
                Adapter.Save();

                string mail = MVCExtensions.getCurrentAdmin().Email;
                MailManager mm = new MailManager();
                mm.EmailBodyHTML = "<p style='font-size:12px;font-style:italic;'>Dit is een automatisch gegenereerd bericht. Gelieve niet te antwoorden daar er niet geantwoord zal worden.</p><h1>ArticulatieOnderzoek </h1><p>"+ model.Firstname + " " + model.Surname + " is geregistreerd door <a href='mailto:" + mail + "?Subject=ArticulatieOnderzoek%20Vraag'>" + HttpContext.User.Identity.Name + " </a></p>";
                MailAddress ma = new MailAddress("*****@*****.**");
                mm.EmailFrom = ma;
                mm.EmailSubject = "ArticulatieOnderzoek - Registratie";
                MailAddress mas = new MailAddress(model.Email.Trim());
                List<MailAddress> masses = new List<MailAddress>();
                masses.Add(mas);
                mm.EmailTos = masses;
                mm.SmtpHost = "smtp.gmail.com";
                mm.SmtpPort = 587;
                mm.IsSSL = true;
                mm.SmtpLogin = "******";
                mm.SmtpPassword = "******";
                mm.SendMail();

                return RedirectToAction("Index", new { message="registerchild"});
            }
            else
            {
                ModelState.AddModelError("", "De opgegeven waarden zijn niet correct of compleet.");
            }
            return View(model);
        }
        public ActionResult Appointment(ChildAppointmentModel model, long children)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User user = Adapter.UserRepository.GetByID(children);
                    string mail = MVCExtensions.getCurrentAdmin().Email;

                    MailManager mm = new MailManager();
                    mm.EmailBodyHTML = "<p style='font-size:12px;font-style:italic;'>Dit is een automatisch gegenereerd bericht. Gelieve niet te antwoorden daar er niet geantwoord zal worden.</p><h1>ArticulatieOnderzoek </h1><p>Een nieuwe afspraak van <a href='mailto:" + mail + "?Subject=ArticulatieOnderzoek%20Afspraak'>" + HttpContext.User.Identity.Name + " </a>voor " + user.Firstname + " " + user.Surname + ". </p><p style='font-style:italic'>" + model.Message + "</p><p>Afspraak om <span class='font-weight:bold;'>" + model.Time.ToString() + "</span> op <span class='font-weight:bold;'>" + model.Date.ToString().Substring(0, model.Date.ToString().Length - 9) + " </span></p><hr /><p>Antwoord en/of bevestig deze afspraak via: <a href='mailto:" + mail + "?Subject=ArticulatieOnderzoek%20Afspraak'>" + HttpContext.User.Identity.Name + "(" + mail + ").</a></p>";
                    MailAddress ma = new MailAddress("*****@*****.**");
                    mm.EmailFrom = ma;
                    mm.EmailSubject = "ArticulatieOnderzoek - nieuwe afspraak";
                    MailAddress mas = new MailAddress(user.Email);
                    List<MailAddress> masses = new List<MailAddress>();
                    masses.Add(mas);
                    mm.EmailTos = masses;
                    mm.SmtpHost = "smtp.gmail.com";
                    mm.SmtpPort = 587;
                    mm.IsSSL = true;
                    mm.SmtpLogin = "******";
                    mm.SmtpPassword = "******";
                    mm.SendMail();
                }
                catch (Exception ex)
                {

                    throw;
                }
                return RedirectToAction("Index", "Home", new { message = "appointment" });
            }
            else
            {
                ICollection<User> chil = Adapter.UserRepository.GetAll().ToList();
                var query = from c in chil select new SelectListItem() { Value = c.ID.ToString(), Text = c.Firstname + " " + c.Surname, Selected = c.ID == children };
                ViewBag.children = query;
            }
            return View(model);
        }
        public ActionResult Contact(string question)
        {
            try
            {
                string mail = MVCExtensions.getCurrentAdmin().Email;
                MailManager mm = new MailManager();
                mm.EmailBodyHTML = "<p style='font-size:12px;font-style:italic;'>Dit is een automatisch gegenereerd bericht. Gelieve niet te antwoorden daar er niet geantwoord zal worden.</p><h1>ArticulatieOnderzoek </h1><p>Een vraag van <a href='mailto:" + mail + "?Subject=ArticulatieOnderzoek%20Vraag'>" + HttpContext.User.Identity.Name + " </a></p><p>" + question + "</p>";
                MailAddress ma = new MailAddress(mail);
                mm.EmailFrom = ma;
                mm.EmailSubject = "ArticulatieOnderzoek - nieuwe vraag";
                MailAddress mas = new MailAddress("*****@*****.**");
                List<MailAddress> masses = new List<MailAddress>();
                masses.Add(mas);
                mm.EmailTos = masses;
                mm.SmtpHost = "smtp.gmail.com";
                mm.SmtpPort = 587;
                mm.IsSSL = true;
                mm.SmtpLogin = "******";
                mm.SmtpPassword = "******";
                mm.SendMail();
            }
            catch (Exception ex)
            {

                throw;
            }
            return RedirectToAction("Index", "Home", new {message = "question" });
        }
        public ActionResult Register(RegisterModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var userModel = viewModel;
                AOMembershipProvider mp = new AOMembershipProvider();

                MembershipCreateStatus status;

                mp.CreateUserBetter(viewModel.Firstname, viewModel.Surname, viewModel.Gender, viewModel.Email, viewModel.Password, out status);
                if (status == MembershipCreateStatus.DuplicateEmail)
                {
                    ModelState.AddModelError("", "Emailadres heeft al een account.");
                }
                else if (status == MembershipCreateStatus.Success)
                {
                    string mail = MVCExtensions.getCurrentAdmin().Email;
                    MailManager mm = new MailManager();
                    mm.EmailBodyHTML = "<p style='font-size:12px;font-style:italic;'>Dit is een automatisch gegenereerd bericht. Gelieve niet te antwoorden daar er niet geantwoord zal worden.</p><h1>ArticulatieOnderzoek </h1><p>U bent geregistreerd door <a href='mailto:" + mail + "?Subject=ArticulatieOnderzoek%20Vraag'>" + HttpContext.User.Identity.Name + " </a></p>";
                    MailAddress ma = new MailAddress("*****@*****.**");
                    mm.EmailFrom = ma;
                    mm.EmailSubject = "ArticulatieOnderzoek - Registratie";
                    MailAddress mas = new MailAddress(viewModel.Email);
                    List<MailAddress> masses = new List<MailAddress>();
                    masses.Add(mas);
                    mm.EmailTos = masses;
                    mm.SmtpHost = "smtp.gmail.com";
                    mm.SmtpPort = 587;
                    mm.IsSSL = true;
                    mm.SmtpLogin = "******";
                    mm.SmtpPassword = "******";
                    mm.SendMail();
                    return RedirectToAction("Index", "Home", new { message = "registered" });

                }
            }
            else
            {
                ModelState.AddModelError("", "De ingevulde gegevens zijn niet correct.");
            }
            return View(viewModel);
        }