BooksServiceSample.Models.BookChaptersRepository.RemoveAsync C# (CSharp) Method

RemoveAsync() public method

public RemoveAsync ( System.Guid id ) : Task
id System.Guid
return Task
        public async Task<BookChapter> RemoveAsync(Guid id)
        {
            BookChapter chapter = await _booksContext.Chapters.SingleOrDefaultAsync(c => c.Id == id);
            if (chapter == null) return null;

            _booksContext.Chapters.Remove(chapter);
            await _booksContext.SaveChangesAsync();
            return chapter;
        }