コード例 #1
0
ファイル: AccountController.cs プロジェクト: JoshIBrown/CafeN
        public PartialViewResult BaristaLogin(string returnUrl)
        {
            BaristaLoginModel model = new BaristaLoginModel();
            using (CafeContext context = new CafeContext())
            {
                model.LocationChoices = context.Locations.ToList().Select(loc => new SelectListItem { Text = loc.Name, Value = loc.LocationID.ToString() });
            }

            ViewBag.ReturnUrl = returnUrl;
            return PartialView("_BaristaSignInPartial", model);
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: JoshIBrown/CafeN
        public ActionResult BaristaLogin(BaristaLoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToRoute("Location_default", new { controller = "Order", action = "Process", id = model.SelectedLocationID });
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");

            //this is here in case we fail login we repopulate to avoid error
            using (CafeContext context = new CafeContext())
            {
                model.LocationChoices = context.Locations.ToList().Select(loc => new SelectListItem { Text = loc.Name, Value = loc.LocationID.ToString() });
            }

            return PartialView("_BaristaSignInPartial", model);
        }