示例#1
0
        public async Task RemovePostAsync(int id)
        {
            var post = await context.Posts.FindAsync(id);

            if (post == null)
            {
                throw new NotFoundException(ErrorCode.ResourceNotFound, "post was not found");
            }

            context.Remove(post);
            await context.SaveChangesAsync();
        }