// GET: Account public ActionResult Index() { using (ourDbContext db = new ourDbContext()) { return(View(db.userAccount.ToList())); } }
public ActionResult Login(FuncionarioModel user, string password) { using (ourDbContext db = new ourDbContext()) { var usr = funcionarioCollection.AsQueryable <FuncionarioModel>().SingleOrDefault(u => u.Nombre == user.Nombre && u.Contraseña == password); //var usr = funcionarioCollection.FindAsync(u => u.Nombre == user.Nombre && u.Contraseña == user.Contraseña); if (usr != null) { if (user.TipoFuncionario == "0") { return(RedirectToAction("CitasDoctorAsync", "Citas")); } if (user.TipoFuncionario == "1") { return(RedirectToAction("Index")); } else { return(RedirectToAction("SecretarioV", "Citas")); } } else { ModelState.AddModelError("", "Nombre de usuario o contraseña incorrectos"); } return(View()); } }
public ActionResult Register(UserAccount account) { if (ModelState.IsValid) { using (ourDbContext db = new ourDbContext()) { db.userAccount.Add(account); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = account.Firstname + " " + account.Lastname + " Registrado correctamente"; } return(View()); }
public ActionResult Login(UserAccount user) { using (ourDbContext db = new ourDbContext()) { var usr = db.userAccount.Single(u => u.Username == user.Username && u.Password == user.Password); if (usr != null) { Session["UserID"] = usr.UserID.ToString(); Session["Username"] = usr.Username.ToString(); return(RedirectToAction("LoggedIn")); } else { ModelState.AddModelError("", "Nombre de usuario o contraseña incorrectos"); } return(View()); } }