Exemple #1
0
 private static void PrintAllInventory()
 {
     using (var repo = new BooksRepo())
     {
         foreach (Books c in repo.GetAll())
         {
             WriteLine(c);
         }
     }
 }
        public async Task<ActionResult> Index()
        {
            try
            {
                var books = await _booksRepo.GetAll();
                ViewData["Books"] = books;

                return View(books);
            }
            catch
            {
                return View();
            } 
        }
Exemple #3
0
        public static async Task InitDB(ApplicationDbContext context)
        {
            BooksRepo   booksRepo = new BooksRepo(context);
            List <Book> books     = await booksRepo.GetAll();

            foreach (var newBook in GetBooks())
            {
                foreach (var book in books)
                {
                    if ((newBook.Title == book.Title &&
                         newBook.Author == book.Author &&
                         newBook.ReleaseDate == book.ReleaseDate &&
                         newBook.Description == book.Description))
                    {
                        goto OuterLoop;
                    }
                }

                await booksRepo.Add(newBook);

OuterLoop:
                continue;
            }
        }