public IActionResult Index(int page = 1, int row = 5, string sortExpression = "Title", string title = "") { title = String.IsNullOrEmpty(title) ? "" : title; List <int> Rows = new List <int> { 5, 10, 15, 20, 50, 100 }; ViewBag.RowID = new SelectList(Rows, row); ViewBag.NumOfRow = (page - 1) * row + 1; ViewBag.Search = title; var PagingModel = PagingList.Create(_repository.GetAllBooks(title, "", "", "", "", "", ""), row, page, sortExpression, "Title"); PagingModel.RouteValue = new RouteValueDictionary { { "row", row }, { "title", title } }; ViewBag.Categories = _repository.GetAllCategories(); ViewBag.LanguageID = new SelectList(_context.Languages, "LanguageName", "LanguageName"); ViewBag.PublisherID = new SelectList(_context.Publishers, "PublisherName", "PublisherName"); ViewBag.AuthorID = new SelectList(_context.Authors.Select(t => new AuthorList { AuthorID = t.AuthorID, NameFamily = t.FirstName + " " + t.LastName }), "NameFamily", "NameFamily"); ViewBag.TranslatorID = new SelectList(_context.Translator.Select(t => new TranslatorList { TranslatorID = t.TranslatorID, NameFamily = t.Name + " " + t.Family }), "NameFamily", "NameFamily"); return(View(PagingModel)); }
private void MainPage_Load(object sender, EventArgs e) { lblNumOfAllBooks.Text = booksRepo.NumOfAllBooks().ToString(); try { var foundBooks = booksRepo.GetAllBooks(); var results = (from a in foundBooks select new { نام = a.AuthorName + " " + a.AuthorFName, موضوع = a.Subject, سال = a.PublishYear, عنوان = a.Title, قیمت = a.Price, کدکتاب = a.Code }).ToList(); dataGridSearchBooks.DataSource = results; } catch (Exception) { } DateTime timer = DateTime.Now; lblTimer.Text = timer.Hour + " : " + timer.Minute + " : " + timer.Second; lblDate.Text = pc.GetYear(timer) + "/" + pc.GetMonth(timer) + "/" + pc.GetDayOfMonth(timer); }
private void FillBooksListBox() { var context = new LibraryContext(); _booksRepository = new BooksRepository(context); booksListBox.DataSource = _booksRepository.GetAllBooks(); booksListBox.DisplayMember = "Name"; booksListBox.ValueMember = "BookId"; }
public IActionResult Get() { return(Ok(JsonConvert.SerializeObject(_booksRepository.GetAllBooks()))); }
public MainViewController(string connectionString) { booksRepo = new BooksRepository(connectionString); readersRepo = new ReadersRepository(connectionString); authorsRepo = new AuthorsRepository(connectionString); CommandsHandler = new Dictionary <string, Func <MainViewArgs, object> > { #region booksCRUD { "get_books", x => { string res = ""; foreach (var book in booksRepo.GetAllBooks()) { res += (book.ToString() + "\n"); } return(res); } }, { "get_book", x => { return(booksRepo.GetBook(x.BookId).ToString()); } }, { "delete_book", x => { return(GetBooLReturnMessage(booksRepo.DeleteBook(x.BookId))); } }, { "insert_book", x => { return(GetBooLReturnMessage(booksRepo.InsertBook(x.Book))); } }, { "update_book", x => { return(GetBooLReturnMessage(booksRepo.UpdateBook(x.Book))); } }, #endregion #region booksAuthors { "AddAuthorToBook", x => { return(GetBooLReturnMessage(booksRepo.AddAuthorToBook(x.AuthorId, x.BookId))); } }, { "DeleteAuthorFromBook", x => { return(GetBooLReturnMessage(booksRepo.DeleteAuthorFromBook(x.AuthorId, x.BookId))); } }, { "GetAuthorsOfBook", x => { string res = ""; foreach (var author in booksRepo.GetAuthorsOfBook(x.BookId)) { res += (author.ToString() + "\n"); } return(res); } }, #endregion #region booksReaders { "AddReaderToBook", x => { return(GetBooLReturnMessage(booksRepo.AddReaderToBook(x.ReaderId, x.BookId))); } }, { "DeleteReaderFromBook", x => { return(GetBooLReturnMessage(booksRepo.DeleteReaderFromBook(x.ReaderId, x.BookId))); } }, { "GetReadersOfBook", x => { string res = ""; foreach (var reader in booksRepo.GetReadersOfBook(x.BookId)) { res += (reader.ToString() + "\n"); } return(res); } }, #endregion #region authorsCRUD { "get_authors", x => { string res = ""; foreach (var author in authorsRepo.GetAllAuthors()) { res += (author.ToString() + "\n"); } return(res); } }, { "get_author", x => { return(authorsRepo.GetAuthor(x.AuthorId).ToString()); } }, { "delete_author", x => { return(GetBooLReturnMessage(authorsRepo.DeleteAuthor(x.AuthorId))); } }, { "insert_author", x => { return(GetBooLReturnMessage(authorsRepo.InsertAuthor(x.Author))); } }, { "update_author", x => { return(GetBooLReturnMessage(authorsRepo.UpdateAuthor(x.Author))); } }, { "get_authorsbooks", x => { string res = ""; foreach (var book in authorsRepo.GetAuthorsBooks(x.AuthorId)) { res += (book.ToString() + "\n"); } return(res); } }, #endregion #region readersCRUD { "get_readers", x => { string res = ""; foreach (var reader in readersRepo.GetAllReaders()) { res += (reader.ToString() + "\n"); } return(res); } }, { "get_reader", x => { return(readersRepo.GetReader(x.ReaderId).ToString()); } }, { "delete_reader", x => { return(GetBooLReturnMessage(readersRepo.DeleteReader(x.ReaderId))); } }, { "insert_reader", x => { return(GetBooLReturnMessage(readersRepo.InsertReader(x.Reader))); } }, { "update_reader", x => { return(GetBooLReturnMessage(readersRepo.UpdateReader(x.Reader))); } }, { "get_readersbooks", x => { string res = ""; foreach (var book in readersRepo.GetReadersBooks(x.ReaderId)) { res += (book.ToString() + "\n"); } return(res); } }, #endregion { "add_random_authors", x => { return(GetBooLReturnMessage(authorsRepo.AddRandomAuthorsToDB(x.RandomCount))); } }, { "search_books", x => { string res = ""; foreach (var book in booksRepo.SearchBooks(x.SearchBookParameters.title, x.SearchBookParameters.minPagesCount, x.SearchBookParameters.maxPagesCount)) { res += (book.ToString() + "\n"); } return(res); } }, { "search_authors", x => { string res = ""; foreach (var author in authorsRepo.SearchAuthors(x.SearchAuthorParameters.Signature, x.SearchAuthorParameters.Name, x.SearchAuthorParameters.MinDate)) { res += (author.ToString() + "\n"); } return(res); } }, { "search_readers", x => { string res = ""; foreach (var reader in readersRepo.SearchReaders(x.SearchReaderParameters.Favouritegenre, x.SearchReaderParameters.Name, x.SearchReaderParameters.Surname)) { res += (reader.ToString() + "\n"); } return(res); } }, }; }