public IActionResult Researcher()
        {
            //Getting user ID
            int resID = IdentityHelper.getUserID(User);
            //Creating default Researhcer Model to view
            ResearcherProfileModel rpm = ProfileResearcherHelper.getdefaultResearcher(resID);

            rpm.ValidInput = true;
            return(View(rpm));
        }
        public IActionResult SaveEmailResearcher(ResearcherProfileModel model)
        {
            //Getting user ID
            int resID = IdentityHelper.getUserID(User);

            //Checking if user input a Email and Name
            if (model.Email == null)
            {
                var err = "A Researcher must have a Email";

                this.ModelState.AddModelError("Email", err.ToString());
            }
            else if (model.Firstname == null)
            {
                var err = "A Researcher must have a Firstname";

                this.ModelState.AddModelError("Firstname", err.ToString());
            }
            else if (model.Lastname == null)
            {
                var err = "A Researcher must have a Lastname";

                this.ModelState.AddModelError("Lastname", err.ToString());
            }
            else
            {
                if (ModelState.IsValid)
                {
                    //Creating local researrhcer object with model parameters.
                    Researcher curResearcher = new Researcher
                    {
                        Email        = model.Email,
                        IdResearcher = resID,
                        FirstName    = model.Firstname,
                        LastName     = model.Lastname
                    };


                    // Call Db here
                    IManageProfileHandler mph = new ManageProfileHandler(new bachelordbContext());
                    mph.ChangeProfileResearcherDB(curResearcher);

                    return(RedirectToAction("Researcher"));
                }
            }

            model            = ProfileResearcherHelper.getdefaultResearcher(resID);
            model.ValidInput = true;
            return(View("Researcher", model));
        }
        public IActionResult SavePasswordResearcher(ResearcherProfileModel rpm)
        {
            int resID = IdentityHelper.getUserID(User);
            var err   = "";

            if (ModelState.IsValid && rpm.Password != null)
            {
                //Creating a local version with changes parametes of Participant obj.
                IManageProfileHandler mph           = new ManageProfileHandler(new bachelordbContext());
                Researcher            curResearcher = new Researcher
                {
                    Email        = rpm.Email,
                    IdResearcher = resID,
                    Password     = rpm.Password,
                };

                var status = mph.ChangePasswordResearcherDB(curResearcher, rpm.OldPassword);
                //Check that old password is correct
                if (status.success)
                {
                    ResearcherProfileModel   srpm   = new ResearcherProfileModel();
                    ResearcherHomepageHelper smodel = new ResearcherHomepageHelper();

                    var curSResearcher = smodel.getResearcher(resID);
                    srpm = ProfileResearcherHelper.convertToModel(curSResearcher, status.success, true);
                    return(View("Researcher", srpm));
                }
                else
                {
                    err = status.errormessage;

                    this.ModelState.AddModelError("OldPassword", err.ToString());
                }
            }
            else
            {
                err = "Must Assign a Password";
                this.ModelState.AddModelError("Password", err.ToString());
            }


            rpm = ProfileResearcherHelper.getdefaultResearcher(resID);
            return(View("Researcher", rpm));
        }