Exemple #1
0
        public ActionResult Login(string naam, string pass)
        {
            RPGRepository rpgrepo = new RPGRepository(rpgsql);

            try
            {
                if (rpgrepo.TryLogin(naam, pass))
                {
                    userview.LoginMessage = "U bent ingelogd.";
                    userview.UserID       = rpgrepo.GetUserId(naam, pass);
                    Session["UserID"]     = userview.UserID;
                    userview.Name         = naam;
                    userview.Password     = pass;
                    userview.Loggedin     = true;
                }
                else
                {
                    userview.LoginMessage = "Verkeerde gebruikersnaam of wachtwoord. Probeer het opnieuw.";
                }
            }
            catch (Exception e)
            {
                userview.LoginMessage = "Connection to database failed. Please connect to VPN.";
            }

            return(View(userview));
        }
        public void Select_Character()
        {
            RPGSQLContext context = new RPGSQLContext();
            RPGRepository repo    = new RPGRepository(context);
            User          user    = new User();

            user.Username = "******";
            user.Password = "******";

            //Get the userid from the logged user
            int userid = repo.GetUserId(user.Username, user.Password);

            //Get the character from the user
            List <Character> characters = repo.GetCharactersFromUser(userid);

            //Send selected character to login view
            RPGController rpgController = new RPGController();

            rpgController.Play(characters[1].CharacterID);
        }