public IHttpActionResult Register(UserLoginModel userToRegister)
        {
            //UserValidator.ValidateAuthCode(userToRegister.AuthCode);
            //UserValidator.ValidateUsername(userToRegister.Username);

            var newUser = toUserEntity(userToRegister);

            this.data.Users.Add(newUser);
            this.data.SaveChanges();

            return Ok();
        }
        public IHttpActionResult Login(UserLoginModel userToLogin)
        {
            //UserValidator.ValidateAuthCode(userToLogin.AuthCode);
            //UserValidator.ValidateUsername(userToLogin.Username);

            var user = this.GetByUsernameAndAuthCode(userToLogin.Username, userToLogin.AuthCode);

            if (user == null)
            {
                return this.BadRequest("Invalid user data.");
            }

            user.SessionKey = UserValidator.GenerateSessionKey(user.UserId);
            this.data.SaveChanges();

            var userLoggedModel = new UserLoggedInModel()
            {
                Username = user.Username,
                SessionKey = user.SessionKey
            };

            return Ok(userLoggedModel);
        }