Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "PostId,Title,Body,Deleted,UserId")] Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(post));
 }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "BlogId,Title,Description,Deleted")] Blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(blog));
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "RoleId,Name,Description,Deleted")] Role role)
 {
     if (ModelState.IsValid)
     {
         db.Entry(role).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(role));
 }
Ejemplo n.º 4
0
        public PartialViewResult DeleteUserRoleReturnPartialView(int userId, int roleId)
        {
            User user = db.Users.Include(usr => usr.Roles).Single <User>(item => item.UserId == userId);

            if (user.Roles.Where(p => p.RoleId == roleId).Count() > 0)
            {
                user.Roles.Remove(user.Roles.Where(p => p.RoleId == roleId).FirstOrDefault());
                //user.LastModified = DateTime.Now;
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                //ApplicationUserManager.RemoveUser4Role(userId, id);

                //SetViewBagData(userId);
            }
            SetViewBagData(user);
            UserItem userModel = Mapper.Map <Domain.User, Models.UserItem>(user);

            return(PartialView("_ListUserRoleTable", userModel));
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "CommentId,Body,UserId,Deleted,PostId")] CommentModel comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostId = new SelectList(db.Posts, "PostId", "Title", comment.PostId);
     return(View(comment));
 }
Ejemplo n.º 6
0
        public ActionResult Edit([Bind(Include = "UserId,UserName,Email,Password,BirthDay,Avatar")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;

                var role = new Role {
                    Name = "System Admin"
                };
                user.Roles.Add(role);

                //Now add this book, with all its relationships, to the database
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }