public ActionResult Check(string area) { PatientMangementDBContext db = new PatientMangementDBContext(); string cookieName = FormsAuthentication.FormsCookieName; //Find cookie name HttpCookie authCookie = HttpContext.Request.Cookies[cookieName]; //Get the cookie by it's name FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); //Decrypt it string UserName = ticket.Name; //You have the UserName! if (UserName != null) { User prd = db.Users.Single(x => x.ID.ToString() == UserName); if (prd.Role == "user") { return(RedirectToAction("Index", "Patient")); } else { return(RedirectToAction("DoctorDashBoard", "Patient")); } } else { return(RedirectToAction("Login", "Account")); } }
// GET: Patient/Details/5 public ActionResult TreatmentHistory() { PatientMangementDBContext db = new PatientMangementDBContext(); string cookieName = FormsAuthentication.FormsCookieName; //Find cookie name HttpCookie authCookie = HttpContext.Request.Cookies[cookieName]; //Get the cookie by it's name FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); //Decrypt it string UserName = ticket.Name; //You have the UserName! var selectedPatient = db.Appointments.Where(d => d.PatientID.ToString() == UserName).OrderByDescending(a => a.AppointmentID).ToList(); return(View(selectedPatient)); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { PatientMangementDBContext dBUserEntities = new PatientMangementDBContext(); string email = value.ToString(); if (!dBUserEntities.Users.Any(emailid => emailid.Username == email)) { return(ValidationResult.Success); } else { return(new ValidationResult("Email already exists")); } } else { ErrorMessage = ErrorMessage ?? validationContext.DisplayName + "is required"; return(new ValidationResult(ErrorMessage)); } }