Database.db db = new Database.db(); // CLASE DE LA BASE DE DATOS (ALMACENA LOS MÉTODOS QUE LLAMAN A LOS PROCEDIMIENTOS ALMACENADOS) public ActionResult Perfil() { DateTime hoy = DateTime.Now; string hoyS = hoy.Year.ToString() + "-" + hoy.Month.ToString() + "-" + hoy.Day.ToString(); string mesYear = hoy.Month.ToString() + "/" + hoy.Year.ToString(); DateTime FEC_FIN = DateTime.Parse(hoyS); ViewBag.mostrar = true; string username = User.Identity.Name; using (var context = new DESACDCEntities()) { // Query for the Blog named ADO.NET Blog var userData = context.tb_Usuarios .Where(b => b.NIC_USU == username) .FirstOrDefault(); //Session["Login"] = model.NIC_USU.ToString(); ViewBag.userData = userData; //ModelState.AddModelError("", "Invalid username or password"); return(View()); } }
public ActionResult Signup(tb_Usuarios model) { using (var context = new DESACDCEntities()) { context.tb_Usuarios.Add(model); context.SaveChanges(); } return(RedirectToAction("Login")); }
public ActionResult Login(Models.Membership model) { using (var context = new DESACDCEntities()) { bool isValid = context.tb_Usuarios.Any(x => x.NIC_USU == model.NIC_USU && x.PWD_USU == model.PWD_USU); if (isValid) { FormsAuthentication.SetAuthCookie(model.NIC_USU, false); //Session["Login"] = model.NIC_USU.ToString(); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Invalid username or password"); return(View()); } }