public IEnumerable <Publisher> Get() { //CRUD using (var _context = new BookStoresDbContext()) { /* Publisher publisher = new Publisher(); // way to Add Data into table in Database * publisher.PublisherName = "Shivaji Sawant"; * * _context.Publishers.Add(publisher); * * _context.SaveChanges();*/ // return _context.Publishers.ToList(); // way to Read Data From Table in Json Format /* Publisher publisher = _context.Publishers.Find(16); // way to update Data from Table * publisher.PublisherName = "Akash Sharma"; * _context.SaveChanges(); * return _context.Publishers.ToList();*/ Publisher publisher = _context.Publishers.Find(16); // Delete The Data from Table _context.Publishers.Remove(publisher); _context.SaveChanges(); return(_context.Publishers.ToList()); } // return new List<Publisher>(); }
public IEnumerable <Author> Get() { using (var context = new BookStoresDbContext()) { return(context.Authors.ToList()); //return context.Authors.Where(any => any.AuthorId == 1).ToList(); } }
public BasicAuthenticationHandler(BookStoresDbContext context, IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { _context = context; }
//public Task<List<Book>> GetAllBooks() //{ // var task = new Task<List<Book>>(() => // { // using (var context = new BookStoresDbContext()) // { // Thread.Sleep(20000); // return context.Books // .Include(book => book.Author) //<== to sprawi, ze w ksiazce beda tez dane autora // .ToList(); // } // }); // task.Start(); // return task; //} public async Task <List <Book> > GetAllBooksAsync() { using (var context = new BookStoresDbContext()) { return(await context.Books .Include(book => book.Author) .ToListAsync()); } }
public async Task <List <Bookstore> > GetBookAvailabilityAsync(int bookId) { using (var context = new BookStoresDbContext()) { return(await context.BookStoresBooks .Include(bookStoreBook => bookStoreBook.BookStore) .Where(bookStoreBook => bookStoreBook.BookId == bookId) .Select(bookStoreBook => bookStoreBook.BookStore) .AsQueryable() .ToListAsync()); } }
public async Task <bool> UpdateBookQuantityAsync(int bookId, uint quantity) { //TODO - Co sie stanie, jezeli tutaj bedzie Book book a nie int bookId using (var context = new BookStoresDbContext()) { var book = context.Books .FirstOrDefault(book => book.Id == bookId); if (book == null) { return(false); } book.CopiesCount = quantity; await context.SaveChangesAsync(); } return(true); }
public PublishersController(BookStoresDbContext context) { _context = context; }
public UsersController(BookStoresDbContext context, IOptions <JWTSettings> jwtSettings) { _jwtSettings = jwtSettings.Value; _context = context; }
public AuthorsController(BookStoresDbContext context) { _context = context; }