Exemple #1
0
        /// <summary>
        /// Load the page where the user can see all of the character linked to his userid.
        /// </summary>
        /// <param name="loginView"></param>
        /// <returns></returns>
        public ActionResult Character(UserLoginViewModel loginView)
        {
            //Add characters from the logged in users to a view
            if (loginView != null)
            {
                Session["UserID"] = loginView.UserID;
            }
            RPGRepository rpgrepo = new RPGRepository(rpgct);

            _charViewModel = new CharacterViewModel
            {
                Characters = rpgrepo.GetCharactersFromUser(loginView.UserID)
            };
            _loginview = loginView;
            return(View(_charViewModel));
        }
        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);
        }
        public void Add_Character()
        {
            RPGSQLContext context  = new RPGSQLContext();
            RPGRepository repo     = new RPGRepository(context);
            string        testname = "TestUserCharacter9";

            //Add a test character to userid 2, with class and race id 2 and the name TestUserCharacter
            repo.AddCharacter(2, 2, 2, testname);

            //Get the character from the database
            Character        character  = null;
            List <Character> characters = repo.GetCharactersFromUser(2);

            foreach (Character chars in characters)
            {
                if (chars.Name == testname)
                {
                    character = chars;
                }
            }

            //Character info test
            Assert.AreEqual(testname, character.Name);
        }