Пример #1
0
        //***       Comments

        ///<exception cref="SystemException"></exception>
        public async Task AddComment(BlogArticleComment inComment)
        {
            await Task.Run(
                () =>
            {
                _blogDBContext.
                BlogArticleComments.
                Add(inComment);

                _blogDBContext.SaveChanges();
            });
        }
Пример #2
0
        ///<exception cref="SystemException"></exception>
        public async Task UpdateComment(BlogArticleComment inComment)
        {
            await Task.Run(
                () =>
            {
                _blogDBContext.
                Entry(_blogDBContext.
                      BlogArticleComments.
                      SingleOrDefault(record => record.Id == inComment.Id)).
                CurrentValues.SetValues(inComment);

                _blogDBContext.SaveChanges();
            });
        }
Пример #3
0
        ///<exception cref="SystemException"></exception>
        public async Task <BlogArticleComment> DeleteComment(long inCommentId)
        {
            return(await Task.Run(
                       () =>
            {
                BlogArticleComment result = _blogDBContext.
                                            BlogArticleComments.
                                            Remove(_blogDBContext.
                                                   BlogArticleComments.
                                                   Attach(new BlogArticleComment
                {
                    Id = inCommentId
                }));

                _blogDBContext.SaveChanges();

                return result;
            }));
        }