public async Task <IActionResult> RetrieveParticipant(RetrieveModel loginModel)
        {
            if (ModelState.IsValid)
            {
                bachelordbContext       db = new bachelordbContext();
                IRetrieveAccountHandler retrieveAccountHandler = new RetrieveAccountHandler(db);

                var status = retrieveAccountHandler.VerifyParticipantDB(loginModel.Email);

                if (status.success)
                {
                    //ResetPassword.
                    IManageProfileHandler mph = new ManageProfileHandler(new bachelordbContext());
                    var oldPassword           = status.participant.Password;
                    status.participant.Password = SecureString.RandomString(6);

                    var changePasswordStatus = mph.ChangePasswordParticipantDB(status.participant, oldPassword);


                    //Sending the mail
                    EmailHelper emailh = new EmailHelper();

                    await emailh.RetrieveAccount(status.participant.Email, status.participant.Password);

                    return(RedirectToAction("Participant", "Welcome"));
                }
                else
                {
                    var err = status.errormessage;
                    this.ModelState.AddModelError("Email", err.ToString());
                }
            }
            return(View("Participant"));
        }
Example #2
0
        public ParticipantHomepageModel CreateParticipantHomepageModel(int partID)
        {
            bachelordbContext        db          = new bachelordbContext();
            Participant              participant = getParticipant(partID);
            IViewStudyHandler        vsh         = new ViewStudyHandler(new bachelordbContext());
            ParticipantHomepageModel participantHomepageModel = new ParticipantHomepageModel();

            //Gets the relevant Study
            participantHomepageModel.relevantStudies = vsh.GetRelevantStudiesDB(participant);

            //Gets the Study that the participant is enrolled in.
            participantHomepageModel.myParticipantStudies = vsh.GetMyParticipantStudiesDB(participant.IdParticipant);

            return(participantHomepageModel);
        }
        public void RegisterResearcher_SuccesfulRegistration_ResearcherIsInDB()
        {
            builder.UseMySql(ConfigStrings.Connectionstring);

            //Retrieves the data from the database and saves in it a context
            bachelordbContext _dbContext = new bachelordbContext(builder.Options);

            //Loads the Researcher table into the context's local-instance
            _dbContext.Researcher.Load();

            //Saves the current number of researchers in the table
            noOfReseachersBefore = _dbContext.Researcher.Local.Count;

            //Executes the registration directly to the database through the controller and to the handler



            RegisterController rc = new RegisterController();

            rc.CreateResearcher(rrvm);
            _dbContext.Researcher.Load();

            //As the context keeps up to date with the database, the new count is one higher than before
            //(manually verified by debugging and checking the database)
            noOfReseachersAfter = _dbContext.Researcher.Local.Count;

            //Attaches the context to the database in order to be able to (in this instance) remove an entry directly.
            _dbContext.Database.EnsureCreated();
            //Removes researcher from database again to avoid clutter
            _dbContext.Remove(_dbContext.Researcher.Last(a => a.LastName == "integrationTestla"));
            _dbContext.SaveChanges();

            //Asserts that the number of researchs in the database is 1 higher after adding one.
            //Not affected by the remove-call, as the counts have already been saved.
            Assert.AreEqual(noOfReseachersAfter, noOfReseachersBefore + 1);
        }
Example #4
0
 public CategoryHandler(bachelordbContext context)
 {
     _context = context;
 }
Example #5
0
 public ComponentHandler(bachelordbContext context)
 {
     _context = context;
 }
 public ViewStudyHandler(bachelordbContext context)
 {
     _context = context;
 }
 public RetrieveAccountHandler(bachelordbContext context)
 {
     _context = context;
 }
 public RegisterHandler(bachelordbContext context)
 {
     _context = context;
 }
Example #9
0
 public LoginHandler(bachelordbContext context)
 {
     _context = context;
 }