public ActionResult Login(string gebruikersnaam, string wachtwoord)
        {
            //RepositoryActiveDirectory rad = new RepositoryActiveDirectory(new ActiveDirectory());
            RepositoryGebruiker rg = new RepositoryGebruiker(new MSSQLGebruiker());

            try
            {
                Gebruiker gebruiker = rg.GebruikerInloggen(gebruikersnaam, wachtwoord);
                if (gebruiker.ID != 0)
                {
                    Session["Gebruiker"] = rg.GetGebruikerByGebruikersnaam(gebruikersnaam);
                    if (gebruiker.GetGebruikerType() == "Bezoeker")
                    {
                        return(RedirectToAction("SocialMedia", "SocialMedia", new { login = true }));
                    }
                    else if (gebruiker.GetGebruikerType() == "Beheerder")
                    {
                        return(RedirectToAction("Index", "Beheer"));
                    }

                    else if (gebruiker.GetGebruikerType() == "Medewerker")
                    {
                        return(RedirectToAction("Index", "Toegangs"));
                    }
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = "Email en/of wachtwoord komen niet overeen";
            }
            return(View());
        }
Exemplo n.º 2
0
        public void GebruikerRegistreren(Gebruiker gebruiker)
        {
            Connect();
            string query = "INSERT INTO Gebruiker(Wachtwoord,Voornaam,Tussenvoegsel,Achternaam,GebruikerType,Aanwezig,Emailadres,Gebruikersnaam)" +
                           "VALUES (@Wachtwoord,@Voornaam, @Tussenvoegsel, @Achternaam, @GebruikerType, @Aanwezig,@Emailadres,@Gebruikersnaam)";

            using (command = new SqlCommand(query, sQLcon))
            {
                command.Parameters.AddWithValue("@Wachtwoord", EncryptString(gebruiker.Wachtwoord));
                command.Parameters.AddWithValue("@Voornaam", gebruiker.Voornaam);
                command.Parameters.AddWithValue("@Tussenvoegsel", gebruiker.Tussenvoegsel);
                command.Parameters.AddWithValue("@Achternaam", gebruiker.Achternaam);
                command.Parameters.AddWithValue("@GebruikerType", gebruiker.GetGebruikerType());
                command.Parameters.AddWithValue("@Aanwezig", 0);
                command.Parameters.AddWithValue("@Emailadres", gebruiker.Email);
                command.Parameters.AddWithValue("@Gebruikersnaam", gebruiker.Gebruikersnaam);
                command.ExecuteNonQuery();
            }

            Close();
        }
Exemplo n.º 3
0
        public void GebruikerRegistreren(Gebruiker gebruiker)
        {
            string wachtwoord = EncryptString(gebruiker.Wachtwoord);

            Connect();
            string query = "INSERT INTO Gebruiker VALUES (@RFID, @Gebruikersnaam, @Wachtwoord, @Voornaam, @Tussenvoegsel, @Achternaam, @GebruikerType, @Aanwezig)";

            using (command = new SqlCommand(query, SQLcon))
            {
                command.Parameters.Add(new SqlParameter("@RFID", gebruiker.RFID));
                command.Parameters.Add(new SqlParameter("@Gebruikersnaam", gebruiker.Gebruikersnaam));
                command.Parameters.Add(new SqlParameter("@Wachtwoord", wachtwoord));
                command.Parameters.Add(new SqlParameter("@Voornaam", gebruiker.Voornaam));
                command.Parameters.Add(new SqlParameter("@Tussenvoegsel", gebruiker.Tussenvoegsel));
                command.Parameters.Add(new SqlParameter("@Achternaam", gebruiker.Achternaam));
                command.Parameters.Add(new SqlParameter("@GebruikerType", gebruiker.GetGebruikerType()));
                command.Parameters.Add(new SqlParameter("@Aanwezig", gebruiker.Aanwezig ? 1 : 0));

                command.ExecuteNonQuery();
            }
            Close();
        }