public ActionResult Login(UserViewModel userViewModel, string ReturnUrl) { if (ModelState.IsValid) { var user = new UserModel().ValidateLogin(userViewModel.Email, userViewModel.Password); if (user != null) { Session["user"] = user; FormsAuthentication.SetAuthCookie(userViewModel.Email, false); return RedirectToLocal(ReturnUrl); } else { ModelState.AddModelError("WebApp.ViewModels.UserViewModel", "The e-mail and/or password entered is invalid. Please try again."); } } return View(userViewModel); }
protected void FillSearchFields() { ViewBag.Genres = new SelectList(new[] { new { Text = "", Key = "" }, new { Text = "Male", Key = "M" }, new { Text = "Female", Key = "F" } }, "Key", "Text"); var cities = new CityModel().GetAllCities(); ViewBag.Cities = new SelectList(cities, "CityId", "CityName"); var region = new RegionModel().GetAllRegions(); ViewBag.Regions = new SelectList(region, "RegionId", "RegionName"); var classifications = new ClassificationModel().GetAllClassifications(); ViewBag.Classifications = new SelectList(classifications, "ClassificationId", "ClassificationName"); var users = new UserModel().GetAllUsers(); ViewBag.Users = new SelectList(users, "UserId", "Name"); SetIsAdmin(); }