コード例 #1
0
ファイル: PostSqlDAO.cs プロジェクト: baesilx/NightCap
        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);
        }
コード例 #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);
        }