//[HttpPost] public ActionResult Login(Login l) { Person p = null; var persons = _personRepository.Get(t => t.email == l.Email); if (persons.Count() == 1) { p = persons.AsQueryable().First(); ViewBag.LoggedIn = true; ViewBag.Manager = p.personTypeId; return View("LoggedIn"); } else return RedirectToAction("Index"); }
public ActionResult TeamMembers() { string email = User.Identity.Name; Person p = _personRepository.Get(x => x.email == email).FirstOrDefault(); var teammembers = new List<Person>(); ViewBag.TeamName = ""; if (p.teamId>0) { teammembers = _personRepository.Get(x => x.teamId == p.teamId && x.id != p.id && p.id>1).OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList(); // Get team name ViewBag.TeamName = ""; var teams = _teamRepository.Get(z => z.id == p.teamId); if (teams.Any()) { ViewBag.TeamName = teams.First().name; } Login l = new Login(); l.Email = p.email; ViewBag.Login = l; } ViewBag.TeamMembers = teammembers; return View(p); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { // get the profile id UProfile up = _userProfileRepository.Get(u => u.UserName == model.UserName).FirstOrDefault(); var person = _personRepository.Get(t => t.userProfileId == up.UserId).FirstOrDefault(); //return RedirectToLocal(returnUrl); Login l = new Login(); l.Email = person.email; return RedirectToAction("Login", "Home", l); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }