public async Task DeleteAsync(Guid entityId) { ArgumentGuard.NotEmpty(entityId, nameof(entityId)); var entity = await GetAsync(entityId); _blogDbContext.Remove(entity); }
public void DeleteBlogPost(Guid Id) { var postToDelete = _blogDbContext .BlogPosts .SingleOrDefault(b => b.Id == Id); _blogDbContext.Remove(postToDelete); _blogDbContext.SaveChanges(); }
public async Task <IActionResult> Delete(int postId) { var toDelete = _blogContext.Posts.Single(c => c.Id == postId); _blogContext.Remove(toDelete); await _blogContext.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> DeleteConfirmed(int id) { var post = await _context.Posts.FirstOrDefaultAsync(p => p.ID == id); //retrieve the details of the id specified var postname = post.Title; _context.Remove(post); await _context.SaveChangesAsync(); TempData["success"] = postname + "Post is Deleted Succesfully"; return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> DeletePost(int id) { var post = await _context.Posts.FindAsync(id); if (post == null) { return(NotFound()); } _context.Remove(post); await _context.SaveChangesAsync(); return(Ok(id)); }
public void Delete(int id) { //clear relations before delete author var blogs = _context.Blog.Where(blog => blog.AuthorId == id); foreach (var b in blogs) { b.AuthorId = null; _context.Blog.Update(b); } _context.SaveChanges(); //delete author var entity = _context.Author.FirstOrDefault(x => x.Id == id); _context.Remove(entity); _context.SaveChanges(); }
public ActionResult Delete(int id) { var comment = db.Comments.Find(id); var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (comment == null) { return(NotFound()); } if (comment.AuthorId != userId && !User.IsInRole("Admin")) { return(BadRequest()); } db.Remove(comment); db.SaveChanges(); return(Ok()); }
public Comment DeleteComment(int id) { _context.Remove(_context.Comments.SingleOrDefault(a => a.Id == id)); _context.SaveChanges(); return(new Comment()); }
public Article DeleteArticle(int id) { _context.Remove(_context.Articles.SingleOrDefault(a => a.Id == id)); _context.SaveChanges(); return(new Article()); }
public void RemovePost(int id) { dbContext.Remove(GetPost(id)); }
public ApplicationUser DelteUser(string id) { _context.Remove(_context.ApplicationUsers.SingleOrDefault(a => a.Id == id)); _context.SaveChanges(); return(new ApplicationUser()); }
public void RemovePost(int id) { _ctx.Remove(GetPost(id)); }
public async Task RemoveAsync(T entity) { using var context = new BlogDbContext(); context.Remove(entity); await context.SaveChangesAsync(); }
public Project DeleteProject(int id) { _context.Remove(_context.Projects.SingleOrDefault(p => p.Id == id)); _context.SaveChanges(); return(new Project()); }