// GET: Admin/Delete/5 public ActionResult Delete(int id) { using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1()) { return(View(dbmodel.Users.Where(x => x.UserID == id).FirstOrDefault())); } }
// GET: Admin/ Index public ActionResult Index() { using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1()) { return(View(dbmodel.Users.ToList())); } }
public ActionResult Create(User user) { try { using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1()) { dbmodel.Users.Add(user); dbmodel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, User user) { try { using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1()) { dbmodel.Entry(user).State = EntityState.Modified; dbmodel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1()) { User user = dbmodel.Users.Where(x => x.UserID == id).FirstOrDefault(); dbmodel.Users.Remove(user); dbmodel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Autherise(MvcLogin.Models.User usermodel1) { using (LoginDateBaseEntities1 db = new LoginDateBaseEntities1()) { var userDetails = db.Users.Where(x => x.UserName == usermodel1.UserName && x.Password == usermodel1.Password).FirstOrDefault(); if (userDetails == null) { usermodel1.LoginErrorMessage = "wrong username or passworg"; return(View("Index", usermodel1)); } else { Session["UserID"] = userDetails.UserID; Session["UserName"] = userDetails.UserName; return(RedirectToAction("Index", "Home", "usermodel1.UserID")); } } }