コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }