Esempio n. 1
0
        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"));
            }
        }
Esempio n. 2
0
        // 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));
        }
Esempio n. 3
0
        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));
            }
        }