Ejemplo n.º 1
0
 private static void AddNewRecords(IList <Books> books)
 {
     using (var repo = new BooksRepo())
     {
         repo.AddRange(books);
     }
 }
Ejemplo n.º 2
0
 private static void AddNewRecord(Books books)
 {
     using (var repo = new BooksRepo())
     {
         repo.Add(books);
     }
 }
Ejemplo n.º 3
0
 public HomeController(ILogger <HomeController> logger, BooksRepo booksRepo, ReservationsRepo reservationsRepo, UserManager <IdentityUser> userManager)
 {
     _logger           = logger;
     _booksRepo        = booksRepo;
     _reservationsRepo = reservationsRepo;
     _userManager      = userManager;
 }
Ejemplo n.º 4
0
 private static void PrintAllInventory()
 {
     using (var repo = new BooksRepo())
     {
         foreach (Books c in repo.GetAll())
         {
             WriteLine(c);
         }
     }
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            foreach (var item in BooksRepo.GetAllBooks())
            {
                Console.WriteLine(item.Name);
                Console.WriteLine("---------------------------------------------------------");
            }


            foreach (var item2 in BooksRepo.GetBooksByGenreId(1))
            {
                Console.WriteLine(item2.Name);
            }
            Console.ReadKey();
        }
Ejemplo n.º 6
0
 private static void UpdateRecord(int bookId)
 {
     using (var repo = new BooksRepo())
     {
         var bookToUpdate = repo.GetOne(bookId);
         if (bookToUpdate != null)
         {
             WriteLine("Before change: " + repo.Context.Entry(bookToUpdate).State);
             bookToUpdate.Genre = "bjhbvjhvj";
             WriteLine("After change: " + repo.Context.Entry(bookToUpdate).State);
             repo.Save(bookToUpdate);
             WriteLine("After Save: " + repo.Context.Entry(bookToUpdate).State);
         }
     }
 }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
 public BooksListController(BooksRepo booksRepo, ReservationsRepo reservationsRepo, UserManager<IdentityUser> userManager)
 {
     _booksRepo = booksRepo;
     _reservationsRepo = reservationsRepo;
     _userManager = userManager;
 }