public ActionResult LogOn(admindetails model, string returnUrl) { OnlineExamEntities4 db = new OnlineExamEntities4(); if (ModelState.IsValid) { var admin = (from adminlist in db.Admins where adminlist.Name == model.UserName && adminlist.Password == model.Password select new { adminlist.Name }).ToList(); if (admin.FirstOrDefault() != null) { FormsAuthentication.SetAuthCookie(model.UserName, false); return(RedirectToAction("Details", "Admin")); } else { ModelState.AddModelError("", "Invalid login credentials."); } } return(View()); }
public ActionResult Details() { admindetails viewdetails = db.Admins.Where(m => m.Name == User.Identity.Name).ToList().Select(val => new admindetails() { Id = val.Id, UserName = val.Name, Password = val.Password }).SingleOrDefault(); return(View(viewdetails)); }
public ActionResult Edit(admindetails mod) { var user = db.Admins.Where(val => val.Id == mod.Id).SingleOrDefault <Admin>(); user.Id = mod.Id; user.Name = mod.UserName; db.SaveChanges(); if (user.Name != null) { FormsAuthentication.SetAuthCookie(mod.UserName, false); return(RedirectToAction("Details", "Admin")); } return(View()); }