public static void InitialData(BookmarkContext context) { context.Database.EnsureCreated(); if (context.Bookmarks.Any()) { return; } context.SaveChanges(); }
public StoreTest() { context = SetupDbContext(nameof(StoreTest)); context.Database.EnsureCreated(); context.Bookmarks.RemoveRange(context.Bookmarks); context.SaveChanges(); var logger = Mock.Of <ILogger <DbBookmarkRepository> >(); repo = new DbBookmarkRepository(context, logger); }
public async Task <ActionResult <byte[]> > GetBookmarkScreenshot(long id) { var bookmarkItem = await _context.BookmarkItems.FindAsync(id); if (bookmarkItem == null) { return(NotFound()); } if (bookmarkItem.Screenshot == null) { bookmarkItem.Screenshot = _screenshotService.CaptureScreenshotAsBytes(bookmarkItem.Url); _context.Update(bookmarkItem); _context.SaveChanges(); } return(File(bookmarkItem.Screenshot, "image/png")); }