コード例 #1
0
        public async Task <bool> Delete(int commentId)
        {
            using (ShowNTellDbContext context = _contextFactory.CreateDbContext())
            {
                bool success = false;

                Comment comment = new Comment()
                {
                    Id = commentId
                };

                try
                {
                    context.Remove(comment);

                    await context.SaveChangesAsync();

                    success = true;
                }
                catch (System.Exception)
                {
                    success = false;
                }

                return(success);
            }
        }