public async Task<ActionResult> Index() { using (var db = new EbookManagerDbContext()) { var catalogRepository = new CatalogRepository(db); var ebooks = await catalogRepository.LoadCatalogWithoutPartsAsync(); var model = new CatalogViewModel(); model.Ebooks.AddRange(ebooks.Select(e => EbookViewModel.FromEbook(e))); return View(model); } }
public async Task<ActionResult> Index() { using (var db = new EbookManagerDbContext()) { var userName = User.Identity.Name; var catalogRepository = new CatalogRepository(db); var ebooks = await catalogRepository.LoadUserCatalog(userName); var model = new CatalogViewModel(); model.Ebooks.AddRange(ebooks.Select(e => EbookViewModel.FromEbook(e))); return View(model); } }