public ActionResult Registration(Register model) { using (var db = new Lab9Context()) { var s = db.Registers.Where(x => x.UserName == model.UserName).FirstOrDefault(); if (s == null) { db.Registers.Add(model); db.SaveChanges(); return(RedirectToAction("Calculation", model)); } }; return(RedirectToAction("Index", "Home")); }
public ActionResult Logout(string Username) { using (var db = new Lab9Context()) { var s = db.Logins.Where(x => x.UserName == Username).FirstOrDefault(); if (s != null) { db.Logins.Remove(s); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } }; return(RedirectToAction("Index", "Home")); }
public ActionResult LoginUser(Login model) { using (var db = new Lab9Context()) { var s = db.Registers.Where(x => x.UserName == model.UserName).FirstOrDefault(); if (s != null) { if (s.Password == model.Password) { db.Logins.Add(model); db.SaveChanges(); //return Redirect(Url.Action("Calculation","Home", new { id = model.UserName })); return(RedirectToAction("Calculation", model)); } } }; return(RedirectToAction("Index", "Home")); }