//
        // GET: /Account/LogOn

        public ActionResult LogOn()
        {
            TimetableSystemEntities systemDB = new TimetableSystemEntities();
            var logOns = from r in systemDB.aspnet_Users
                         select r.UserName;
            SelectList            userNames = new SelectList(logOns);
            List <SelectListItem> temp      = new List <SelectListItem>(userNames);

            ViewBag.UserNames = temp;

            return(View());
        }
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            TimetableSystemEntities systemDB = new TimetableSystemEntities();

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            var logOns = from r in systemDB.aspnet_Users
                         select r.UserName;
            SelectList            userNames = new SelectList(logOns);
            List <SelectListItem> temp      = new List <SelectListItem>(userNames);

            ViewBag.UserNames = temp;


            // If we got this far, something failed, redisplay form
            return(View(model));
        }