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

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

            await ReadingListRepository <Book> .UpsertBookForUser(myBookToSave);

            return("Success");
        }
Exemplo n.º 2
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());
            }
        }
Exemplo n.º 3
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());
            }
        }