public static ParticipantProfileModel getdefaultParticipant(int id) { ParticipantHomepageHelper helper = new ParticipantHomepageHelper(); ParticipantProfileModel ppm = new ParticipantProfileModel(); var participant = helper.getParticipant(id); ppm.Email = participant.Email; ppm.Id = id; ppm.English = participant.English; ppm.ValidInput = false; return(ppm); }
public IActionResult SavePasswordParticipant(ParticipantProfileModel ppm) { //Getting user ID int partID = IdentityHelper.getUserID(User); ppm.SuccesChangePassword = false; var err = ""; if (ModelState.IsValid && ppm.Password != null) { //Creating a local version with changes parametes of Participant obj. IManageProfileHandler mph = new ManageProfileHandler(new bachelordbContext()); Participant curpart = new Participant { Email = ppm.Email, IdParticipant = partID, Password = ppm.Password, }; var status = mph.ChangePasswordParticipantDB(curpart, ppm.OldPassword); //Check that old password is correct if (status.success) { ParticipantHomepageHelper helper = new ParticipantHomepageHelper(); var curParticipants = helper.getParticipant(partID); //Creates a new part obj. since SuccesChange has to be true to show dialog ParticipantProfileModel sppm = ProfileParticipantHelper.convertToModel(curParticipants, status.success, true); return(View("Participant", sppm)); } else { //Error message if Password did not match err = status.errormessage; this.ModelState.AddModelError("OldPassword", err.ToString()); } } else { //Error message if Password was not put in. err = "Must Assign a Password"; this.ModelState.AddModelError("Password", err.ToString()); } return(View("Participant", ProfileParticipantHelper.getdefaultParticipant(partID))); }