コード例 #1
0
        public ActionResult AdminLogOnPAYG(RoomBookingViewModel model, string returnUrl, string signIn)
        {
            if (string.IsNullOrEmpty(model.UserName))
            {
                ModelState.AddModelError("", "The Pin Code entered is invalid.");
            }
            else
            {
                var guestCredential = AppSecurity.GetUserByPinCode(model.UserName);

                if (guestCredential == null)
                {
                    ModelState.AddModelError("", "The Pin Code entered is invalid.");
                }
                else
                {
                    if (guestCredential.EndDate < DateTime.Today)
                    {
                        ModelState.AddModelError("", "The Pin Code entered has expired.");
                    }
                    else
                    {
                        bool guestLogin;

                        if (AppSecurity.Login(guestCredential.Person.Username, guestCredential.Person.Password, out guestLogin))
                        {
                            if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                                !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                            {
                                return(Redirect(returnUrl));
                            }

                            //var tt = GetName();

                            return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin, auth = "req" }));
                        }

                        //return View("_ErrorMessage", new BaseViewModel { Errormsg = "The user name or password provided is incorrect." });
                        ModelState.AddModelError("", "The user name or password provided is incorrect.");
                        return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = true, auth = "req" }));
                    }
                }
            }

            return(View("PAYGLogin", new BaseViewModel()));
        }