Example #1
0
        public async Task <IActionResult> Create([Bind("ID,Voornaam,Achternaam,Geslacht,Land,Email")] Nieuwsbriefmodel nieuwsbriefmodel)
        {
            if (ModelState.IsValid)
            {
                string      bericht = ". Bedankt voor het aanmelden, vanaf nu ontvangt u wekelijks onze nieuwsbrief, afmelden kan door te mailen naar dit emailadres.";
                string      to      = nieuwsbriefmodel.Email;
                string      from    = "*****@*****.**";
                string      subject = "Nieuwsbrief";
                string      body    = @"Geachte" + " " + nieuwsbriefmodel.Voornaam + " " + nieuwsbriefmodel.Achternaam + bericht;
                MailMessage message = new MailMessage(from, to, subject, body);

                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.EnableSsl   = true;
                client.Credentials = new NetworkCredential("*****@*****.**", "project2019");
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
                client.Send(message);


                _context.Add(nieuwsbriefmodel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nieuwsbriefmodel));
        }
        public async Task <IActionResult> Create([Bind("id,vraag,antwoord")] FAQ fAQ)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fAQ);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fAQ));
        }
        public async Task <IActionResult> Create([Bind("id,naam,prijs,omschrijving")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("ID,Voornaam,Achternaam,Telefoonnummer,Land,Email")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }