private void Redirect() { books.Clear(); if (string.IsNullOrEmpty(input.value)) { return; } if (Directory.Exists(input.value)) { DirectoryInfo root = new DirectoryInfo(input.value); foreach (FileInfo file in root.GetFiles("*.txt", SearchOption.AllDirectories)) { BookInformation book = new BookInformation() { name = file.Name, path = file.FullName, filter = false, }; books.Add(book); } } }
public HttpResponseMessage Update([FromBody] BookInformation bookStatus) { // Stuff... // Retrieve clients IP# var clientIp = Request.GetClientIpString(); }
public LibrarianBookInfoSearchForm(IClientInformationRegister register, ILibraryCardRegister libraryCardRegister, ClientInformation client, BookInformation book) { clientInformationRegister = register; currentClient = client; currentBook = book; this.libraryCardRegister = libraryCardRegister; InitializeComponent(); }
private void RefreshBookList(ref BookInformation now, ref ListViewItem line) { for (int i = 0; i < 6; i++) { line.SubItems[1 + i].Text = now.BookInfo._rawData_[i]; } line.SubItems[7].Text = "是"; }
public BookInfoControlForm(FormViewMode mode, IWorkspaceStockman workspaceStockman, BookInformation book = null) { viewMode = mode; currentBook = book; libraryManagment = workspaceStockman.LibraryOperations; publishHouseRegister = workspaceStockman.PublishHouseInformationRegister; InitializeComponent(); }
public void SummaryShouldReturnBookDescriptionIfItsNull() { var bookInformation = new BookInformation { Model = new Book { Description = null } }; bookInformation.Summary(150).Should().Be(null); }
public void SummaryShouldReturnBookDescriptionWhenItsShorterThanTheSummaryLengthRequested() { var bookInformation = new BookInformation { Model = new Book { Description = "four" } }; bookInformation.Summary(5).Should().Be("four"); }
public void SummaryShouldReturnTheBookDescriptionTruncatedToTheCharacterLimitIfThereAreNoSpacesAfterTheLimit() { var bookInformation = new BookInformation { Model = new Book { Description = "wordword" } }; bookInformation.Summary(4).Should().Be("word"); }
public void SummaryShouldReturnTheBookDescriptionUpToTheFirstSpaceAfterTheCharacterLimitRequested() { var bookInformation = new BookInformation { Model = new Book { Description = "word word" } }; bookInformation.Summary(2).Should().Be("word"); }
private void ButtonSave_Click(object sender, EventArgs e) { if (FormViewMode.Create == viewMode) { currentBook = new BookInformation(); libraryManagment.AddBook(PackageBookInformation(currentBook)); } else { libraryManagment.EditBook(PackageBookInformation(currentBook)); } }
public void ShouldUseRepositoryWhenCreatingABook() { var book = new Book(); var bookInformation = new BookInformation(book); var mockedRepo = GetMockedRepo(); mockedRepo.Setup(repo => repo.Create(book)).Returns(new Book()); var booksController = new BooksController(mockedRepo.Object); booksController.Create(bookInformation); mockedRepo.Verify(repo => repo.Create(book)); }
public Form_Item(BookInformation reff, BookEvaluaion value, int uid, string name, bool isNew = true) { InitializeComponent(); ucl = name; __BookID = reff.BookID; __UserID = uid; __EvalID = Cipher.ModPositive(Guid.NewGuid().GetHashCode(), __MOD__); book = reff; isNewComer = isNew; if (isNewComer) rank = new BookEvaluaion(__EvalID, __BookID, __UserID, new _Evaluaion()); else rank = value; OnDisplay(); }
public async Task <ActionResult <String> > PostBook(BookInformation book) { List <BookInformation> booklist = _context.BookItems.Where(a => a.Id.Contains(book.Id, StringComparison.OrdinalIgnoreCase)).ToList(); if (booklist.Any()) { return(Conflict()); } _context.BookItems.Add(book); await _context.SaveChangesAsync(); //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem); return("Book Succesfully added"); }
public void EditBookShouldNotSaveWhenBookIsInvalid() { var book = new Book(); var bookInformation = new BookInformation(book); var mockedRepo = new Mock <Repository>(); var booksController = new BooksController(mockedRepo.Object); mockedRepo.Setup(repo => repo.Edit(book)); booksController.ModelState.AddModelError("test error", "test exception"); var result = (ViewResult)booksController.Edit(bookInformation); mockedRepo.Verify(repo => repo.Edit(book), Times.Never(), "failing model validation should prevent updating book"); Assert.AreEqual("There were problems saving this book", booksController.TempData["flashError"]); }
private void ButtonSearch_Click(object sender, EventArgs e) { BookInformation book = WorkspaceStockman.BookFinding.FindByTitle(textBoxSearch.Text); if (book != null) { using (BookInfoControlForm bookForm = new BookInfoControlForm(NViewHelper.FormViewMode.Edit, WorkspaceStockman, book)) { Hide(); bookForm.ShowDialog(); Show(); } } }
public ViewResult Details(int id) { var book = Repository.Get <Book>(id); if (book == null) { throw new HttpException(404, "The requested book could not be found"); } var bookPosts = book.Posts.Select(post => new BookPostInformation(book.Id, post)).ToList(); var bookInformation = new BookInformation(book, bookPosts); ViewBag.Title = bookInformation.Model.Title; ViewBag.MetaDescription = bookInformation.Summary(155); return(View(bookInformation)); }
public void ShouldUpdateBookOnEditPost() { var editedBook = new Book { Id = 1, Title = "A book" }; var editedBookInformation = new BookInformation(editedBook); var mockedRepo = GetMockedRepo(); mockedRepo.Setup(repo => repo.Edit(editedBook)); var booksController = new BooksController(mockedRepo.Object); var viewResult = (RedirectToRouteResult)booksController.Edit(editedBookInformation); mockedRepo.Verify(repo => repo.Edit <Book>(editedBook), Times.Once()); Assert.AreEqual("Updated A book successfully", booksController.TempData["flashSuccess"]); Assert.AreEqual(1, viewResult.RouteValues["id"]); }
public ActionResult Create(BookInformation bookInformation) { if (!ModelState.IsValid) { TempData["flashError"] = ProblemsSavingBookMessage; return(View(bookInformation)); } if (!IsIsbnUnique(bookInformation)) { TempData["flashError"] = "The ISBN number already exists"; return(View(bookInformation)); } var createdBook = Repository.Create(bookInformation.Model); TempData["flashSuccess"] = string.Format("Added {0} successfully", createdBook.Title); return(RedirectToAction("Details", new { id = createdBook.Id })); }
public void ShouldReturnBookFoundInGoogleApi() { _libraryRepositoryMock.Setup(x => x.FindBookWithGivenIsbn("9788375106626")).Returns(() => null); var bookInformationFromApi = new BookInformation { ISBN = "9788375106626", Title = "Diuna", Author = "Frank Herbert" }; _googleApiServiceMock.Setup(x => x.GetByIsbn("9788375106626")).Returns(bookInformationFromApi); var handlerResults = _findBook.Handle(new FindBookQuery { ISBN = "9788375106626" }); Assert.Contains(handlerResults, book => bookInformationFromApi.Author == book.Author); }
public Form_Item(BookInformation reff, BookEvaluaion value, int uid, string name, bool isNew = true) { InitializeComponent(); ucl = name; __BookID = reff.BookID; __UserID = uid; __EvalID = Cipher.ModPositive(Guid.NewGuid().GetHashCode(), __MOD__); book = reff; isNewComer = isNew; if (isNewComer) { rank = new BookEvaluaion(__EvalID, __BookID, __UserID, new _Evaluaion()); } else { rank = value; } OnDisplay(); }
public ActionResult Edit(BookInformation editedBookInformation) { if (!ModelState.IsValid) { TempData["flashError"] = ProblemsSavingBookMessage; return(View(editedBookInformation)); } if (!IsIsbnUnique(editedBookInformation)) { TempData["flashError"] = "The Book Edit was not saved because the provided ISBN number already exists"; return(View(editedBookInformation)); } Repository.Edit(editedBookInformation.Model); TempData["flashSuccess"] = string.Format("Updated {0} successfully", editedBookInformation.Model.Title); return(RedirectToAction("Details", new { id = editedBookInformation.Model.Id })); }
public void ShouldRedirectToDetailsPageWhenBookIsCreated() { var book = new Book { Title = "The Book" }; var bookInformation = new BookInformation(book); var mockedRepo = GetMockedRepo(); mockedRepo.Setup(repo => repo.Create(book)).Returns(new Book { Id = 1, Title = "The Book" }); var booksController = new BooksController(mockedRepo.Object); var viewResult = (RedirectToRouteResult)booksController.Create(bookInformation); Assert.IsNotNull(viewResult); Assert.AreEqual("Added The Book successfully", booksController.TempData["flashSuccess"]); Assert.AreEqual(1, viewResult.RouteValues["id"]); }
private BookInformation PackageBookInformation(BookInformation book) { Dictionary <int, bool> mapInventoryCodes = new Dictionary <int, bool>(); foreach (var code in listBoxInventoryCodeAvailable.Items) { mapInventoryCodes.Add(Convert.ToInt32(code, CultureInfo.CurrentCulture), false); } ; foreach (var code in listBoxInventoryCodeNotAvailable.Items) { mapInventoryCodes.Add(Convert.ToInt32(code, CultureInfo.CurrentCulture), true); } ; book.InventoryCode = mapInventoryCodes; book.Title = textBoxTitle.Text; book.FullTitle = textBoxFullTitle.Text; book.ISBN = Convert.ToInt32(textBoxIsbn.Text, CultureInfo.CurrentCulture); book.Language = textBoxLanguage.Text; book.PublishHouse = publishHouseRegister.FindByName(textBoxPublishHouseResult.Text); book.PublishDate = dateTimePickerPublish.Value; book.Annotation = textBoxAnnotation.Text; book.BookSeries = textBoxSeries.Text; string[] authorsNames = textBoxAuthors.Text.Split(new char[] { ',', ' ' }); List <AuthorInformation> authors = new List <AuthorInformation>(); foreach (string name in authorsNames) { authors.Add(new AuthorInformation() { Name = name }); } book.Authors = authors.ToArray(); book.Subject = new SubjectInformation() { Name = textBoxSubject.Text }; return(book); }
internal void BookAddOperation() { output = new GetOutputType().Output; GetApproachToInteractWithTheDatabase.GetOutputTypeApproach(output); BookStoreSimple bStore = GetApproachToInteractWithTheDatabase.Approach(); bStore.GetOutputTypeApproach(output); BookInformation.GetOutputTypeApproach(output); BookInformation bookInformation = new BookInformation(bStore.GetGenres()); bStore.AddBook( bookInformation.BookTitle, bookInformation.PublicationYear, bookInformation.PublishingHouse, bookInformation.AuthorName, bookInformation.GenreId, bookInformation.Number, bookInformation.Price); }
private void listViewBooks_DoubleClick(object sender, EventArgs e) { int lineNumber = this.listView_Books.SelectedIndices[0]; var line = this.listView_Books.Items[lineNumber]; string bid = line.SubItems[0].Text; int id = int.Parse(bid); BookInformation book; if (!BookList.tryFind(id, out book)) { return; } BookEvaluaion rank; bool isNewComer = !BookEval.tryFind(id, out rank); Form_Item item = new Form_Item(book, rank, idNumeric, ucl, isNewComer); item.ReturnBook += (o, e1) => { if (!e1.CanUpdate) { return; } BookInformation info = e1.Book; BookEvaluaion value = e1.Rank; if (isNewComer) { BookEval.Add(value); } else { BookEval.ReplaceTo(id, value); } RefreshBookList(ref info, ref line); }; item.ShowDialog(); }
private void ButtonSearchBook_Click(object sender, EventArgs e) { if (selectedClient != null) { BookInformation book = workspaceLibrarian.BookFinding.FindByTitle(textBoxManageBook.Text); if (book != null) { using (LibrarianBookInfoSearchForm bookForm = new LibrarianBookInfoSearchForm(workspaceLibrarian.ClientInformationRegister, workspaceLibrarian.LibraryCardRegister, selectedClient, book)) { Hide(); bookForm.ShowDialog(); Show(); } } } else { MessageBox.Show(Properties.Resources.clientNotSpecified, Properties.Resources.failed, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); } }
public Book(int id, BookDetail detail, BookInformation info) { Id = id; Detail = detail; Info = info; }
private IEnumerable <Book> SearchByIsbn(BookInformation editedBookInformation) { return(Repository.Search <Book>(b => (b.Isbn == editedBookInformation.Model.Isbn && b.Id != editedBookInformation.Model.Id)) .ToList()); }
public AddArguments(BookDetail detail, BookInformation info) { Detail = detail; Info = info; }
protected override void Seed(LibraryMVC.DataAccess.LibraryContext context) { //Book instance Book book = new Book { Condition = "Mint", IsRented = true, Loans = new List <Loan>() }; Author author = new Author { Name = "John Doe", Nation = "SE", IsAlive = false, HasNobelPrize = true, BookInformations = new List <BookInformation>() }; BookInformation bookinformation = new BookInformation { Title = "Sample Title", ISBN = "000-001", Description = "Description...", Category = Category.Romance, PublishedYear = 1111, Position = "Shelf", Authors = new List <Author>(), Books = new List <Book>() }; Loan loan = new Loan { Start = DateTime.Now, End = DateTime.Now.AddMonths(3), IsReturned = false, Books = new List <Book>() }; LoanTaker loantaker = new LoanTaker { Name = "Some Loaner", MembershipNumber = "12", Contact = "*****@*****.**", Loans = new List <Loan>() }; //Mapping - data book.BookInformation = bookinformation; bookinformation.Books.Add(book); bookinformation.Authors.Add(author); author.BookInformations.Add(bookinformation); book.Loans.Add(loan); loan.Books.Add(book); loan.LoanTaker = loantaker; loantaker.Loans.Add(loan); //Add to db context.LoanTakers.Add(loantaker); context.SaveChanges(); /* * context.Database.ExecuteSqlCommand("Book_Insert @Condition, @IsRented, @BookInformationID", * new SqlParameter { ParameterName = "@Condition", Value = "Near Mint" }, * new SqlParameter { ParameterName = "@IsRented", Value = 0 }, * new SqlParameter("@BookInformationID", 1) * * ); */ // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }
private bool IsIsbnUnique(BookInformation bookInformation) { return(bookInformation.Model.Isbn == null || !SearchByIsbn(bookInformation).Any()); }
public void EditBookShouldNotSaveWhenBookIsInvalid() { var book = new Book(); var bookInformation = new BookInformation(book); var mockedRepo = new Mock<Repository>(); var booksController = new BooksController(mockedRepo.Object); mockedRepo.Setup(repo => repo.Edit(book)); booksController.ModelState.AddModelError("test error", "test exception"); var result = (ViewResult)booksController.Edit(bookInformation); mockedRepo.Verify(repo => repo.Edit(book), Times.Never(), "failing model validation should prevent updating book"); Assert.AreEqual("There were problems saving this book", booksController.TempData["flashError"]); }
public void ShouldRedirectToDetailsPageWhenBookIsCreated() { var book = new Book { Title = "The Book" }; var bookInformation = new BookInformation(book); var mockedRepo = GetMockedRepo(); mockedRepo.Setup(repo => repo.Create(book)).Returns(new Book { Id = 1, Title = "The Book"}); var booksController = new BooksController(mockedRepo.Object); var viewResult = (RedirectToRouteResult)booksController.Create(bookInformation); Assert.IsNotNull(viewResult); Assert.AreEqual("Added The Book successfully", booksController.TempData["flashSuccess"]); Assert.AreEqual(1, viewResult.RouteValues["id"]); }
public void ShouldUpdateBookOnEditPost() { var editedBook = new Book { Id = 1, Title = "A book" }; var editedBookInformation = new BookInformation(editedBook); var mockedRepo = GetMockedRepo(); mockedRepo.Setup(repo => repo.Edit(editedBook)); var booksController = new BooksController(mockedRepo.Object); var viewResult = (RedirectToRouteResult)booksController.Edit(editedBookInformation); mockedRepo.Verify(repo => repo.Edit<Book>(editedBook), Times.Once()); Assert.AreEqual("Updated A book successfully", booksController.TempData["flashSuccess"]); Assert.AreEqual(1, viewResult.RouteValues["id"]); }