예제 #1
0
        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();
        }
예제 #3
0
        public async Task <IActionResult> Delete(int postId)
        {
            var toDelete = _blogContext.Posts.Single(c => c.Id == postId);

            _blogContext.Remove(toDelete);
            await _blogContext.SaveChangesAsync();

            return(Ok());
        }
예제 #4
0
        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)));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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();
        }
예제 #7
0
        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());
        }
예제 #8
0
 public Comment DeleteComment(int id)
 {
     _context.Remove(_context.Comments.SingleOrDefault(a => a.Id == id));
     _context.SaveChanges();
     return(new Comment());
 }
예제 #9
0
 public Article DeleteArticle(int id)
 {
     _context.Remove(_context.Articles.SingleOrDefault(a => a.Id == id));
     _context.SaveChanges();
     return(new Article());
 }
예제 #10
0
파일: PostService.cs 프로젝트: ezsofi/Blog
 public void RemovePost(int id)
 {
     dbContext.Remove(GetPost(id));
 }
예제 #11
0
 public ApplicationUser DelteUser(string id)
 {
     _context.Remove(_context.ApplicationUsers.SingleOrDefault(a => a.Id == id));
     _context.SaveChanges();
     return(new ApplicationUser());
 }
예제 #12
0
 public void RemovePost(int id)
 {
     _ctx.Remove(GetPost(id));
 }
예제 #13
0
 public async Task RemoveAsync(T entity)
 {
     using var context = new BlogDbContext();
     context.Remove(entity);
     await context.SaveChangesAsync();
 }
예제 #14
0
 public Project DeleteProject(int id)
 {
     _context.Remove(_context.Projects.SingleOrDefault(p => p.Id == id));
     _context.SaveChanges();
     return(new Project());
 }