Esempio n. 1
0
 /// <summary>
 /// Method that saves new usersecurityquestion data into the 'usersecurityquestions' table.
 /// </summary>
 /// <param name="userSecurityQuestion"></param>
 public void SaveUserSecurityQuestion(usersecurityquestion userSecurityQuestion)
 {
     using (var context = new TreasureHuntEntities())
     {
         context.usersecurityquestions.AddObject(userSecurityQuestion);
         context.SaveChanges();
         context.ObjectStateManager.ChangeObjectState(userSecurityQuestion, System.Data.EntityState.Added);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Method that will attempt to save the new admininistrator and their details into the datbase.
        /// </summary>
        /// <param name="newUser"></param>
        private async void SaveUser(user newUser)
        {
            //Save the new user in the database
            long userId = await this.serviceClient.SaveUserAsync(newUser);

            //Save their company details in the database
            companydetail newCompany = new companydetail();

            newCompany.UserId          = userId;
            newCompany.CompanyName     = this.companyName;
            newCompany.CompanyPassword = this.companyPassword;

            await this.serviceClient.saveCompanyAsync(newCompany);

            //Save this new user as an administrative user in the database
            userrole newUserRole = new userrole();

            newUserRole.UserId = userId;
            newUserRole.RoleId = 1;

            await this.serviceClient.SaveUserRoleAsync(newUserRole);

            //Saving their security question and answer in the database
            usersecurityquestion newSecurityQuestion = new usersecurityquestion();

            newSecurityQuestion.UserId             = userId;
            newSecurityQuestion.SecurityQuestionId = CurrentSecurityQuestion.SecurityQuestionId;
            newSecurityQuestion.Answer             = SecurityAnswer;
            await this.serviceClient.SaveUserSecurityQuestionAsync(newSecurityQuestion);

            PopupDisplayed = false;

            MessageBoxResult messageBox = MessageBox.Show("You have successfully registered!", "Success");

            Messenger.Default.Send <UpdateViewMessage>(new UpdateViewMessage()
            {
                UpdateViewTo = "LoginViewModel"
            });

            EmailAddress    = String.Empty;
            Password        = String.Empty;
            Name            = String.Empty;
            CompanyName     = String.Empty;
            CompanyPassword = String.Empty;
            securityAnswer  = String.Empty;
        }
        public ResetPasswordViewModelTest()
        {
            serviceClient = new Mock<ITreasureHuntService>();
            viewModel = new ResetPasswordViewModel(serviceClient.Object);

            currentUser = new user();
            currentUser.UserId = 1;
            currentUser.Name = "Emma";
            currentUser.Password = "******";

            usersecurityquestion currentUserSecurityDetails = new usersecurityquestion();
            currentUserSecurityDetails.Answer = "answer";
            currentUserSecurityDetails.SecurityQuestionId = 1;
            currentUserSecurityDetails.UserId = 1;
            currentUserSecurityDetails.UserSecurityId = 1;

            securityquestion currentSecurityQuestion = new securityquestion();
            currentSecurityQuestion.SecurityQuestionId = 1;

            CurrentSecurityQuestion = currentSecurityQuestion;
            SecurityAnswer = currentUserSecurityDetails;
            CurrentUser = currentUser;  
        }
        public ResetPasswordViewModelTest()
        {
            serviceClient = new Mock<ITreasureHuntService>();
            viewModel = new ResetPasswordViewModel(serviceClient.Object);

            currentUser = new user();
            currentUser.UserId = 1;
            currentUser.Name = "Emma";
            currentUser.Password = "******";

            usersecurityquestion currentUserSecurityDetails = new usersecurityquestion();
            currentUserSecurityDetails.Answer = "answer";
            currentUserSecurityDetails.SecurityQuestionId = 1;
            currentUserSecurityDetails.UserId = 1;
            currentUserSecurityDetails.UserSecurityId = 1;

            securityquestion currentSecurityQuestion = new securityquestion();
            currentSecurityQuestion.SecurityQuestionId = 1;

            CurrentSecurityQuestion = currentSecurityQuestion;
            SecurityAnswer = currentUserSecurityDetails;
            CurrentUser = currentUser;
        }
        /// <summary>
        /// Method that will attempt to save the new admininistrator and their details into the datbase.
        /// </summary>
        /// <param name="newUser"></param>
        private async void SaveUser(user newUser)
        { 
            //Save the new user in the database
            long userId = await this.serviceClient.SaveUserAsync(newUser);

            //Save their company details in the database
            companydetail newCompany = new companydetail();
            newCompany.UserId = userId;
            newCompany.CompanyName = this.companyName;
            newCompany.CompanyPassword = this.companyPassword;

            await this.serviceClient.saveCompanyAsync(newCompany);

            //Save this new user as an administrative user in the database
            userrole newUserRole = new userrole();
            newUserRole.UserId = userId;
            newUserRole.RoleId = 1;

            await this.serviceClient.SaveUserRoleAsync(newUserRole);

            //Saving their security question and answer in the database
            usersecurityquestion newSecurityQuestion = new usersecurityquestion();
            newSecurityQuestion.UserId = userId;
            newSecurityQuestion.SecurityQuestionId = CurrentSecurityQuestion.SecurityQuestionId;
            newSecurityQuestion.Answer = SecurityAnswer;
            await this.serviceClient.SaveUserSecurityQuestionAsync(newSecurityQuestion);

            PopupDisplayed = false;
         
            MessageBoxResult messageBox = MessageBox.Show("You have successfully registered!", "Success");

            Messenger.Default.Send<UpdateViewMessage>(new UpdateViewMessage() { UpdateViewTo = "LoginViewModel" });

            EmailAddress = String.Empty;
            Password = String.Empty;
            Name = String.Empty;
            CompanyName = String.Empty;
            CompanyPassword = String.Empty;
            securityAnswer = String.Empty ;
        }