コード例 #1
0
ファイル: HomePageController.cs プロジェクト: JesperMoon/FYP
        public ActionResult PractitionerLogin(LoginInfo loginInfo)
        {
            LoginInfo result = new LoginInfo();

            if (Request.Form["Submit"] != null)
            {
                if (ModelState.IsValid == true)
                {
                    PractitionerProcess process = new PractitionerProcess();
                    result = process.PractitionerLogin(loginInfo);

                    TempData["Deleted"]   = "";
                    TempData["Pending"]   = "";
                    TempData["Incorrect"] = "";

                    //Account found
                    if (result.AccountNo != Guid.Empty)
                    {
                        //Check Status
                        if (result.AccountStatus.Equals(ConstantHelper.AccountStatus.Active))
                        {
                            PractitionerBaseViewModel vm = new PractitionerBaseViewModel();
                            vm.AccId = result.AccountNo;
                            FormsAuthentication.SetAuthCookie(result.AccountNo.ToString(), false);
                            return(RedirectToAction("Profile", "Practitioner", vm));
                        }

                        else if (result.AccountStatus.Equals(ConstantHelper.AccountStatus.Deleted))
                        {
                            //Account deleted
                            TempData["Deleted"] = "Deleted";
                            loginInfo.Password  = "";

                            return(View(loginInfo));
                        }

                        else if (result.AccountStatus.Equals(ConstantHelper.AccountStatus.Pending))
                        {
                            //Account pending
                            TempData["Pending"] = "Pending";
                            loginInfo.Password  = "";

                            return(View(loginInfo));
                        }
                    }
                    else
                    {
                        //Account not found
                        TempData["Incorrect"] = "Incorrect";
                        loginInfo.Password    = "";

                        return(View(loginInfo));
                    }
                }
            }

            return(View(loginInfo));
        }