Exemple #1
0
        public async Task AddBookmarkAsync(string title, uint pageNumber)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException("title is empty", nameof(title));
            }
            if (pageNumber < 1 || pageNumber > PageCount)
            {
                throw new ArgumentOutOfRangeException(nameof(pageNumber));
            }

            var bookmarkDto = new EfBookmarkDto
            {
                Title      = title,
                PageNumber = pageNumber,
                EfBookDto  = _efBookDto
            };

            _context.Bookmarks.Add(bookmarkDto);
            await SaveChangesAsync();

            var bookmark = new EfBookmark(bookmarkDto, _context);

            _bookmarks.Add(bookmark);
        }
Exemple #2
0
 public EfBookmark(EfBookmarkDto efBookmarkDto, EfBooksContext context)
 {
     _efBookmarkDto = efBookmarkDto;
     _context       = context;
 }