Beispiel #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);
        }
Beispiel #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");
        }
Beispiel #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);
 }