//[ValidateAntiForgeryToken] public ActionResult Edit(User user) { if (Session["userEmail"] != null) { User targetsUser = new MyDoctorDB.User(); targetsUser = DoctorDBContext.Users.Where(u => u.ID == user.ID).FirstOrDefault(); if (targetsUser != null) { if (ModelState.IsValid) { user.Password = EncryptPassword.encryptPassword(user.Password); targetsUser.FirstName = user.FirstName; targetsUser.LastName = user.LastName; targetsUser.Email = user.Email; targetsUser.PhoneNumber = user.PhoneNumber; targetsUser.Password = user.Password; targetsUser.DateOfBirth = user.DateOfBirth; doctordb.UpdateUser(targetsUser); ViewBag.useremail = targetsUser.Email; return(View("PatientDashboard")); } } return(View(user)); } return(RedirectToAction("LogIn", "Home")); }
public ActionResult ConfirmationDeleting2(UserDeleteInfo deletedUser) { if (Session["userEmail"] != null) { if (ModelState.IsValid) { string DeletedUserPassword = EncryptPassword.encryptPassword(deletedUser.password); User targetUser = DoctorDBContext.Users.Where(u => u.ID == deletedUser.ID).FirstOrDefault(); if (targetUser != null) { if (targetUser.Password.Equals(DeletedUserPassword)) { Delete(targetUser); Logout(); return(RedirectToAction("Index", "Home")); } else { return(View()); } } } return(View()); } return(RedirectToAction("LogIn", "Home")); }
public override bool IsValid(object value) { if (value is string) { if (value.ToString().Length < 6) { return(false); } string password = EncryptPassword.encryptPassword(value.ToString()); if (user.Password == password) { return(true); } } return(false); }
public override bool IsValid(object value) { if (value is string) { string UserPassword = value.ToString(); if (UserPassword.Length < 6) { return(false); } string EncryptedUserPassword = EncryptPassword.encryptPassword(UserPassword); if (user.Password == EncryptedUserPassword) { return(true); } } return(false); }
public ActionResult LogIn(UserLogIn user) { if ((user.Password == null) || (user.Email == null)) { return(View(user)); } //encrypt the password string pass = EncryptPassword.encryptPassword(user.Password); //Check The Existance of the user var userLoggedIn = DoctorDBContext.Users.SingleOrDefault(u => u.Email == user.Email && u.Password == pass); if (userLoggedIn != null) { //if it's a patient display the patient dahsboard if (userLoggedIn.PatientID != 0) { Session["userEmail"] = userLoggedIn.Email; Session["LoggedPatientID"] = userLoggedIn.ID; ViewBag.Patientid = userLoggedIn.PatientID; return(RedirectToAction("PatientDashboard", "Patient", new { username = userLoggedIn.Email })); } //if it's a doctor display doctor dashboard else { ViewBag.triedOnce = "Yes"; Session["username"] = userLoggedIn.FirstName; ViewBag.Doctorid = userLoggedIn.DoctorID; //return View("PatientDashboard", new { username = userLoggedIn.FirstName }); return(RedirectToAction("DoctorDashboard", "Doctor", new { username = userLoggedIn.FirstName })); } } else { ViewBag.triedOnce = "Yes"; return(View()); } }
//[ValidateAntiForgeryToken] public ActionResult PatientRegister(User user) { if (Session["userEmail"] == null) { User newUser = new User(); Patient patient = new Patient(); if (ModelState.IsValid) { //Encrypt The Password Using MD5 Encryption string EncryptedPassword = EncryptPassword.encryptPassword(user.Password); //set user password to encrypted password user.Password = EncryptedPassword; //this User is a Patient user.PatientID = 1; //set User's Data to patient patient.users = user; //set patient into database doctordb.SetPatient(patient); //Start A new Session Session["userEmail"] = user.Email; //store the id of the patient Session["LoggedPatientID"] = user.PatientID; //store the email of the patient ViewBag.useremail = user.Email; return(View("PatientDashboard")); } return(View(user)); } return(View("PatientDashboard")); }
public ActionResult LogIn(UserLogIn user) { if ((user.Password == null) || (user.Email == null)) { return(View(user)); } string pass = EncryptPassword.encryptPassword(user.Password); //Check The Existance of the user var userLoggedIn = DoctorDBContext.Users.SingleOrDefault(u => u.Email == user.Email && u.Password == pass); if (userLoggedIn != null) //found the user { ViewBag.triedOnce = "Yes"; Session["username"] = userLoggedIn.FirstName; return(View("PatientDashboard", new { username = userLoggedIn.FirstName })); } else { ViewBag.triedOnce = "Yes"; return(View()); } }