Example #1
0
 public ActionResult Edit([Bind(Include = "Id,Body,CreateTime,BlogId,PosterId")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BlogId   = new SelectList(db.Blogs, "Id", "Title", comment.BlogId);
     ViewBag.PosterId = new SelectList(db.Users, "Id", "UserName", comment.PosterId);
     return(View(comment));
 }
Example #2
0
        public async Task <bool> EditPostAsync(EditPostViewModel post, string authorId)
        {
            var model = _mapper.Map <Post>(post);

            model.AuthorId = authorId;

            var entity = await _context.Posts.FindAsync(model.Id);

            _context.Entry(entity).CurrentValues.SetValues(model);

            var success = await _context.SaveChangesAsync() > 0;

            if (success)
            {
                return(true);
            }

            return(false);
        }
 public void Update(Category entity)
 {
     _context.Categories.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }
Example #4
0
 public void Update(T entity)
 {
     _dbSet.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }