public void ValidIsbn10ShouldReturnTrue() { var isbn = GenerateValidIsbn10(); var result = BookUtils.VerifyIsbn(isbn); Assert.IsTrue(result); }
public void NullIsbnShouldReturnFalse() { string isbn = null; var result = BookUtils.VerifyIsbn(isbn); Assert.IsFalse(result); }
public void InvalidIsbn10ShouldReturnFalse() { var isbn = GenerateInvalidIsbn10(); var result = BookUtils.VerifyIsbn(isbn); Assert.IsFalse(result); }
public void WhitespaceIsbnShouldReturnFalse() { string isbn = " "; var result = BookUtils.VerifyIsbn(isbn); Assert.IsFalse(result); }
public void EmptyIsbnShouldReturnFalse() { string isbn = string.Empty; var result = BookUtils.VerifyIsbn(isbn); Assert.IsFalse(result); }
public async Task <string> GetDescription(string isbn) { if (isbn == null || BookUtils.VerifyIsbn(isbn) == false) { throw new Exception("Book isbn is not valid."); } return(await _access.SelectDescriptionWithId(isbn)); }
public async Task <bool> DeleteWithIsbnAsync(string isbn) { if (isbn == null || BookUtils.VerifyIsbn(isbn) == false) { throw new Exception("Book isbn is not valid."); } return(await _access.DeleteWithIdAsync(isbn)); }
public Task <bool> DeleteWithIsbnAsync(string isbn) { if (isbn == null || BookUtils.VerifyIsbn(isbn) == false) { throw new ArgumentException("Isbn is not valid."); } return(_access.DeleteWithIsbnAsync(isbn)); }
public async Task <List <BookCopy> > GetByIsbnAsync(string isbn) { if (isbn == null || BookUtils.VerifyIsbn(isbn) == false) { throw new ArgumentException("Invalid isbn"); } var bookCopyMaps = await _access.GetByIsbnAsync(isbn); return(bookCopyMaps.Select(bookCopyMap => _mapper.Unmap(bookCopyMap)).ToList()); }
private void Save_Button_Click(object sender, RoutedEventArgs e) { if (!float.TryParse(ratingTextBox.Text, out float rating)) { MessageBox.Show("The value of rating is invalid. Enter it again"); return; } if (!int.TryParse(countTextBox.Text, out int count)) { MessageBox.Show("The value of count is invalid. Enter it again"); return; } if (!int.TryParse(shelfTextBox.Text, out int shelf)) { MessageBox.Show("The value of shelf is invalid. Enter it again"); return; } Book.Title = titleTextBox.Text; Book.Rating = rating; Book.Description = descriptionTextBox.Text; Book.Section = BookUtils.ParseSection(sectionComboBox.Text); Book.Authors = (bookAuthors.ItemsSource as IList <Author>); BookService.SaveOrUpdate(Book); if (!BookCounter.IsPresent(Book.Id)) { BookCounter.AddNew(Book.Id, count); } else { BookCounter.SetCount(Book.Id, count); } if (!BookArranger.IsPresent(Book.Id)) { BookArranger.AddEntry(Book.Id, shelf); } else { BookArranger.Set(Book.Id, shelf); } // if book is saved // it will be displayed onto main datagrid BookIsSaved = true; MessageBox.Show("Done"); }
private void Section_Selection_Changed(object sender, RoutedEventArgs args) { ComboBox box = (ComboBox)sender; BookSection section = BookUtils.ParseSection(box.SelectedValue.ToString()); BookDtoConverter dtoConverter = new BookDtoConverter { BookCounter = BookCounter, BookArranger = BookArranger }; allBooksBySection.ItemsSource = dtoConverter.ConvertBooks(BookService.FindBySection(section)); allBooksBySection.Items.Refresh(); }
public async Task <Book> GetByIsbnAsync(string isbn) { if (isbn == null || BookUtils.VerifyIsbn(isbn) == false) { throw new Exception("Book isbn is not valid."); } var bookMap = await _access.SelectWithIdAsync(isbn); if (bookMap == null) { return(null); } return(_mapper.Unmap(bookMap)); }
//XPathXSLSample4/form1.cs private void button1_Click(object sender, System.EventArgs e) { //new XPathDocument XPathDocument doc=new XPathDocument("..\\booksxpath.xml"); //new XslTransform XslTransform transForm=new XslTransform(); transForm.Load("..\\booksarg.xsl"); //new XmlTextWriter since we are creating a new xml document XmlWriter xw=new XmlTextWriter("..\\argSample.xml",null); //create the XslArgumentList and new BookUtils object XsltArgumentList argBook=new XsltArgumentList(); BookUtils bu=new BookUtils(); //this tells the argumentlist about BokUtils argBook.AddExtensionObject("urn:ProCSharp",bu); //new XPathNavigator XPathNavigator nav=((IXPathNavigable)doc).CreateNavigator(); //do the transform transForm.Transform(nav,argBook,xw); xw.Close(); MessageBox.Show("argSample.xml created"); }
public async Task <bool> DeleteAsync(Book item) { if (item == null) { throw new NullReferenceException("Book cannot be null."); } if (item.Isbn == null || BookUtils.VerifyIsbn(item.Isbn) == false) { throw new Exception("Book isbn is not valid."); } var bookMap = _mapper.Map(item); if (bookMap == null) { throw new NullReferenceException("Book map cannot be null."); } return(await _access.DeleteOneAsync(bookMap)); }
//XPathXSLSample4/form1.cs private void button1_Click(object sender, System.EventArgs e) { //new XPathDocument XPathDocument doc = new XPathDocument("..\\booksxpath.xml"); //new XslTransform XslTransform transForm = new XslTransform(); transForm.Load("..\\booksarg.xsl"); //new XmlTextWriter since we are creating a new xml document XmlWriter xw = new XmlTextWriter("..\\argSample.xml", null); //create the XslArgumentList and new BookUtils object XsltArgumentList argBook = new XsltArgumentList(); BookUtils bu = new BookUtils(); //this tells the argumentlist about BokUtils argBook.AddExtensionObject("urn:ProCSharp", bu); //new XPathNavigator XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator(); //do the transform transForm.Transform(nav, argBook, xw); xw.Close(); MessageBox.Show("argSample.xml created"); }
private void Search() { var ratingFromStr = searchByRatingFrom.Text; var ratingToStr = searchByRatingTo.Text; var title = searchByTitle.Text; var section = searchBySection.Text; var author = (Author)searchByAuthor.SelectedItem; float ratingFrom; float ratingTo; IList <Book> temp; ISet <BookDto> result = new HashSet <BookDto>(); BookDtoConverter converter = new BookDtoConverter { BookCounter = BookCounter, BookArranger = BookArranger }; if (ratingFromStr.Length != 0 && ratingToStr.Length != 0) { if (!float.TryParse(ratingFromStr, out ratingFrom) || !float.TryParse(ratingToStr, out ratingTo)) { MessageBox.Show("Enter the valid value of rating"); return; } temp = BookService.FindByRating(ratingFrom, ratingTo); foreach (var book in temp) { result.Add(converter.ConvertBook(book)); } } if (!(author is null)) { foreach (var book in author.Books) { result.Add(converter.ConvertBook(book)); } } temp = BookService.FindByTitle(title); foreach (var book in temp) { result.Add(converter.ConvertBook(book)); } if (section.Length != 0 && !section.Equals("None")) { temp = BookService.FindBySection(BookUtils.ParseSection(section)); foreach (var book in temp) { result.Add(converter.ConvertBook(book)); } } searchResultGrid.ItemsSource = result; searchResultGrid.Items.Refresh(); searchByAuthor.SelectedItem = null; }
public BookService(ILogger logger) { _logger = logger; _logger.Info("Inizializing BookService"); bookUtils = new BookUtils(); }