示例#1
0
 // GET: Admin/Delete/5
 public ActionResult Delete(int id)
 {
     using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1())
     {
         return(View(dbmodel.Users.Where(x => x.UserID == id).FirstOrDefault()));
     }
 }
示例#2
0
 // GET: Admin/ Index
 public ActionResult Index()
 {
     using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1())
     {
         return(View(dbmodel.Users.ToList()));
     }
 }
示例#3
0
        public ActionResult Create(User user)
        {
            try
            {
                using (LoginDateBaseEntities1 dbmodel = new LoginDateBaseEntities1())
                {
                    dbmodel.Users.Add(user);
                    dbmodel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#4
0
        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());
            }
        }
示例#5
0
        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());
            }
        }
示例#6
0
        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"));
                }
            }
        }