예제 #1
0
        public ActionResult Index()
        {
            var vm = new PatientListViewModel();

            var physician = physicianSvc.GetPhysician(User.Identity.Name);

            if (physician != null)
            {
                vm.Patients = physician.Patients;
            }

            return(View(vm));
        }
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!System.Web.Security.FormsAuthentication.Authenticate(model.UserName, model.Password))
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }

            var roleList  = new List <string>();
            var physician = physicianSvc.GetPhysician(model.UserName);

            if (physician != null)
            {
                roleList.Add("physician");
            }
            var patient = PatientSvc.GetPatientByUserName(model.UserName);

            if (patient != null)
            {
                roleList.Add("patient");
            }
            string roles = string.Join(",", roleList);

            var authTicket = new System.Web.Security.FormsAuthenticationTicket(
                1,
                model.UserName, //user id
                DateTime.Now,
                DateTime.Now.AddMinutes(System.Web.Security.FormsAuthentication.Timeout.Minutes),
                model.RememberMe,
                roles,
                "/");

            HttpCookie cookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName,
                                               System.Web.Security.FormsAuthentication.Encrypt(authTicket));

            Response.Cookies.Add(cookie);
            return(RedirectToLocal(returnUrl));
        }
예제 #3
0
        public ActionResult Physician(int id)
        {
            var physician = physicianSvc.GetPhysician(id);

            return(View(physician));
        }