public async Task <string> StartUp()
        {
            ReadingListRepository <Recommendation> .Initialize();

            await ReadingListRepository <Recommendation> .StartUpMode();

            return("success");
        }
        public async Task <IEnumerable <Recommendation> > GetRecommendations()
        {
            ReadingListRepository <Recommendation> .Initialize();

            IEnumerable <Recommendation> recomms = (IEnumerable <Recommendation>) await ReadingListRepository <Recommendation> .GetBooks(d => d.type == "recommendation");

            return(recomms);
        }
        public async Task <string> DeleteBook(string id)
        {
            ReadingListRepository <Book> .Initialize();

            await ReadingListRepository <Book> .RemoveBookForUser(id);

            return("success");
        }
Example #4
0
        public async Task <IActionResult> Deploy()
        {
            ReadingListRepository <Recommendation> .Initialize();

            await ReadingListRepository <Recommendation> .StartUpMode();

            return(RedirectToAction("Index", "ReadingList"));
        }
        public async Task <IEnumerable <Book> > GetUsersBooks()
        {
            ReadingListRepository <Book> .Initialize();

            IEnumerable <Book> myBooks = (IEnumerable <Book>) await ReadingListRepository <Book> .GetBooksForUser(b => b.reader == Settings.readerName);

            return(myBooks);
        }
        public async Task <Book> GetBook(string id)
        {
            //get the requested record.
            ReadingListRepository <Book> .Initialize();

            IEnumerable <Book> myBooks = (IEnumerable <Book>) await ReadingListRepository <Book> .GetBooksForUser(b => b.id == id.ToString());

            return(myBooks.First());
        }
        public async Task <string> SaveBook([FromBody] string content)
        {
            ReadingListRepository <Book> .Initialize();

            Book myBookToSave = JsonConvert.DeserializeObject <Book>(content);

            await ReadingListRepository <Book> .UpsertBookForUser(myBookToSave);

            return("Success");
        }
Example #8
0
        // GET: ReadingList
        public async Task <ActionResult> Index()
        {
            ReadingListViewModel readingListContent = new ReadingListViewModel();

            readingListContent.LibraryBooks = await ReadingListRepository <Recommendation> .GetBooks(d => d.type == "recommendation");

            ReadingListRepository <Book> .Initialize();

            readingListContent.MyBooks = (IEnumerable <Book>) await ReadingListRepository <Book> .GetBooksForUser(b => b.reader == Settings.readerName);

            return(View(readingListContent));
        }
Example #9
0
        // GET: ReadingList/Delete/5
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                ReadingListRepository <Book> .Initialize();

                await ReadingListRepository <Book> .RemoveBookForUser(id);
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("Index"));
        }
Example #10
0
        public async Task <ActionResult> Edit(string id, IFormCollection collection)
        {
            try
            {
                Book updatedBook = SaveCollectionAsBook(collection);

                ReadingListRepository <Book> .Initialize();

                await ReadingListRepository <Book> .UpsertBookForUser(updatedBook);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #11
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            try
            {
                Book myNewBookToSave = SaveCollectionAsBook(collection);

                ReadingListRepository <Book> .Initialize();

                await ReadingListRepository <Book> .UpsertBookForUser(myNewBookToSave);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=ReadingList}/{action=Index}/{id?}");
            });

            ReadingListRepository <Recommendation> .Initialize();
        }