public async Task<HttpResponseMessage> GetEbooks() { using (var db = new EbookManagerDbContext()) { var userName = "******"; var catalogRepository = new CatalogRepository(db); var userEbooks = await catalogRepository.LoadUserCatalog(userName); return Request.CreateResponse(HttpStatusCode.OK, userEbooks); } }
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); } }