public BookDataModel GetBookByIdentifier(int bookId) { string sql = "select book_id, book_title, book_author, num_pages, published_date from books where book_id = @book_id;"; BookDataModel result = _dbConnection.Query <BookDataModel>(sql, new { book_id = bookId }).FirstOrDefault(); return(result); }
public bool Filter(BookDataModel bookDataModel) { Book book = bookDataModel.Book; return(string.IsNullOrEmpty(filterText) || (!string.IsNullOrEmpty(book.Title) && book.Title.Contains(filterText, StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrEmpty(book.Author) && book.Author.Contains(filterText, StringComparison.CurrentCultureIgnoreCase))); }
public int InsertNewBook(BookDataModel dataModel) { //This quey performs an insert and also returns back the identifier for the record that was inserted. We do this so the database can generate a unique id for our new book string sql = "INSERT INTO BOOKS (book_title, book_author, num_pages, published_date, available) values (@BOOK_TITLE, @BOOK_AUTHOR, @NUM_PAGES, @PUBLISHED_DATE, @AVAILABLE); select last_insert_id();"; int result = _dbConnection.Query <int>(sql, dataModel).FirstOrDefault(); return(result); }
public bool Filter(BookDataModel bookDataModel) { if (string.IsNullOrEmpty(filterText)) { return(true); } Book book = bookDataModel.Book; return(string.IsNullOrEmpty(book.Title) || book.Title.IndexOf(filterText, StringComparison.CurrentCultureIgnoreCase) >= 0 || string.IsNullOrEmpty(book.Author) || book.Author.IndexOf(filterText, StringComparison.CurrentCultureIgnoreCase) >= 0); }
public void ConstructorTest() { var book = new Book(); var dummyCommand = new DelegateCommand(() => {}); AssertHelper.ExpectedException <ArgumentNullException>(() => new BookDataModel(null !, null !)); AssertHelper.ExpectedException <ArgumentNullException>(() => new BookDataModel(book, null !)); var bookDataModel = new BookDataModel(book, dummyCommand); Assert.AreEqual(book, bookDataModel.Book); Assert.AreEqual(dummyCommand, bookDataModel.LendToCommand); }
public int AddNewBook(BookRequest aNewBook) { BookDataModel dataModel = new BookDataModel() { BOOK_AUTHOR = aNewBook.Author, BOOK_TITLE = aNewBook.Title, NUM_PAGES = aNewBook.NumPages, PUBLISHED_DATE = aNewBook.PublishedDate }; int Identifier = _libraryQuery.InsertNewBook(dataModel); return(Identifier); }
private void RemoveBook() { // Use the BookCollectionView, which represents the sorted/filtered state of the books, to determine the next book to select. IEnumerable <BookDataModel> booksToExclude = bookListViewModel.SelectedBooks.Except(new[] { bookListViewModel.SelectedBook }); BookDataModel nextBook = CollectionHelper.GetNextElementOrDefault(bookListViewModel.BookCollectionView.Except(booksToExclude), bookListViewModel.SelectedBook); foreach (BookDataModel book in bookListViewModel.SelectedBooks.ToArray()) { entityService.Books.Remove(book.Book); } bookListViewModel.SelectedBook = nextBook ?? bookListViewModel.BookCollectionView.LastOrDefault(); bookListViewModel.Focus(); }
public ActionResult Hall(long cinemaId, long hallId, long seanceId, string dateSeance, long timeSeanceId, long movieId) { var seanceData = seanceService.GetDataFromAPISeanceByMovieTheaterAndDate(cinemaId, movieId, dateSeance); var movieModel = mapperMovieModel.Map <Movie, MovieBookModel>(movieService.GetFromAPI(movieId)); var theaterModel = mapperTheaterModel.Map <Theater, TheaterBookModel>(seanceData.Theaters[0]); var date = DateTime.ParseExact(dateSeance, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); var seanceModel = mapperSeanceModel.Map <Seance, SeanceModel>(seanceData.Seances.Find(s => s.Id == seanceId)); var timeSeance = seanceModel.Times.Find(t => t.Id == timeSeanceId); var hallName = seanceData.Halls.Find(h => h.Id == seanceModel.HallId).Name; var technology = (timeSeance.Is3D == true) ? "3D" : "2D"; var pricesModel = mapperPriceModel.Map <List <Price>, List <PriceModel> >(PriceFormer.Prices(timeSeance.Prices)); var bookData = new BookDataModel(timeSeanceId, hallName, date, movieModel, timeSeance, theaterModel, technology, pricesModel); //ViewBag.LastElId = bookService.GetLastElId(); return(View(bookData)); }
public void RemoveSelectedBook(BookDataModel bookDataModel) { selectedBooks.Remove(bookDataModel); }
public void AddSelectedBook(BookDataModel bookDataModel) { selectedBooks.Add(bookDataModel); }