private static void AddNewRecords(IList <Books> books) { using (var repo = new BooksRepo()) { repo.AddRange(books); } }
private static void AddNewRecord(Books books) { using (var repo = new BooksRepo()) { repo.Add(books); } }
public HomeController(ILogger <HomeController> logger, BooksRepo booksRepo, ReservationsRepo reservationsRepo, UserManager <IdentityUser> userManager) { _logger = logger; _booksRepo = booksRepo; _reservationsRepo = reservationsRepo; _userManager = userManager; }
private static void PrintAllInventory() { using (var repo = new BooksRepo()) { foreach (Books c in repo.GetAll()) { WriteLine(c); } } }
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(); }
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); } } }
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; } }
public BooksListController(BooksRepo booksRepo, ReservationsRepo reservationsRepo, UserManager<IdentityUser> userManager) { _booksRepo = booksRepo; _reservationsRepo = reservationsRepo; _userManager = userManager; }