Exemplo n.º 1
0
        public bool DeletePost(int postId)
        {
            bool isDeleted = false;

            try
            {
                using (NightCapDBContext nightCapDBContext = new NightCapDBContext())
                {
                    Post post = nightCapDBContext.Posts.Find(postId);
                    nightCapDBContext.Remove(post);
                    nightCapDBContext.SaveChanges();
                    isDeleted = true;
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(isDeleted);
        }
Exemplo n.º 2
0
        public bool DeleteComment(int commentId)
        {
            bool isDeleted = false;

            try
            {
                using (NightCapDBContext nightCapDBContext = new NightCapDBContext())
                {
                    Comment comment = nightCapDBContext.Comments.Find(commentId);
                    nightCapDBContext.Remove(comment);
                    nightCapDBContext.SaveChanges();
                    isDeleted = true;
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(isDeleted);
        }