Esempio n. 1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {

                db.User.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "role", user.RoleID);
            return View(user);
        }
Esempio n. 2
0
        public ActionResult Add(int? id)
        {
            int userid = Convert.ToInt32(Session["ID"]);
            int friendid = Convert.ToInt32(id);

            //get friendname
            User u =new User();
            u = db.User.Find(id);
            Friend friend = new Friend() { UserID = userid, Friend_ID = friendid, User = db.User.Find(id) ,FriendName = u.Name};
            db.Friend.Add(friend);
            db.SaveChanges();

            return RedirectToAction("Index");
        }
Esempio n. 3
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "role", user.RoleID);
     return View(user);
 }