public void BookManagement_Should_Find_Book_In_DB() { var bookManagement = new BookManagement(_dbManager); bookManagement.AddToCollection(new Author { Name = "Robert C. Martin", ID = Guid.NewGuid() }); var book = bookManagement.GetBookFromApi("9780132350884"); bookManagement.AddToCollection(book); var foundBook = bookManagement.FindBook("Title", "Clean Code"); Assert.Equal(book.ID, foundBook.ID); Assert.Equal(book.Isbn, foundBook.Isbn); Assert.Equal(book.Title, foundBook.Title); Assert.Equal(book.Publisher, foundBook.Publisher); Assert.Equal(book.Language, foundBook.Language); Assert.Equal(book.PageCount, foundBook.PageCount); Assert.Equal(book.Description, foundBook.Description); Assert.Equal(book.AverageRating, foundBook.AverageRating); Assert.Equal(book.Authors[0].ID, foundBook.Authors[0].ID); Assert.Equal(book.PublishedDate, foundBook.PublishedDate); Assert.Equal(book.MaturityRating, foundBook.MaturityRating); Assert.Equal(book.Authors[0].Name, foundBook.Authors[0].Name); _dbManager.Dispose(); }
static void Main(string[] args) { BookManagement bookObj = new BookManagement(); Console.WriteLine("******Welcome To Online Book Shopping System******\n"); bookObj.viewBooks(); getUserChoice(); }
public void BookManagement_Should_Add_Author_To_DB() { var bookManagement = new BookManagement(_dbManager); bookManagement.AddToCollection(_dummyAuthor); _dbManager.Dispose(); }
public void BookManagement_Should_Add_Book_To_DB() { var bookManagement = new BookManagement(_dbManager); var book = bookManagement.GetBookFromApi("9780132350884"); bookManagement.AddToCollection(book); _dbManager.Dispose(); }
public void BookManagement_Should_Find_Author_In_DB() { var bookManagement = new BookManagement(_dbManager); bookManagement.AddToCollection(_dummyAuthor); Assert.NotNull(bookManagement.FindAuthor("Name", _dummyAuthor.Name)); _dbManager.Dispose(); }
public void BookManagement_Should_Delete_Author_From_DB() { var bookManagement = new BookManagement(_dbManager); bookManagement.AddToCollection(_dummyAuthor); bookManagement.RemoveFromCollection(_dummyAuthor); Assert.Null(bookManagement.FindAuthor("Name", _dummyAuthor.Name)); _dbManager.Dispose(); }
public void BookManagement_Should_Delete_Book_From_DB() { var bookManagement = new BookManagement(_dbManager); var book = bookManagement.GetBookFromApi("9780132350884"); bookManagement.AddToCollection(book); bookManagement.RemoveFromCollection(book); Assert.Null(bookManagement.FindBook("Title", book.Title)); _dbManager.Dispose(); }
public void BookManagement_Should_Update_Book_In_DB() { var bookManagement = new BookManagement(_dbManager); var book = bookManagement.GetBookFromApi("9780132350884"); bookManagement.AddToCollection(book); book.Title = "Modified Title"; bookManagement.Update(book); Assert.NotNull(bookManagement.FindBook("Title", book.Title)); _dbManager.Dispose(); }
public ActionResult SearchCopy(string copyId, string userId) { GetRole(); ViewBag.UserId = userId; ViewBag.CopyId = copyId; var search = repo.SearchCopy(copyId); if (search == null) { ViewBag.Error = "对不起,本书已经借出!"; return(View()); } BookManagement bm = new BookManagement() { BookName = search.name, ISBN = search.isbn, Index = search.book_index }; return(View(bm)); }
public void BookManagement_Should_Return_Book_From_Api() { var bookManagement = new BookManagement(_dbManager); bookManagement.AddToCollection(new Author { Name = "Robert C. Martin", ID = Guid.NewGuid() }); var book = bookManagement.GetBookFromApi("9780132350884"); _dbManager.Dispose(); Assert.Equal("en", book.Language); Assert.Equal(431, book.PageCount); Assert.Equal(4.5, book.AverageRating); Assert.Equal("Clean Code", book.Title); Assert.Equal("9780132350884", book.Isbn); Assert.Equal("NOT_MATURE", book.MaturityRating); Assert.Equal("Pearson Education", book.Publisher); Assert.Equal("2009", book.PublishedDate.Year.ToString()); Assert.Equal("Robert C. Martin", book.Authors.FirstOrDefault()?.Name); Assert.StartsWith("Looks at the principles and clean code", book.Description); }
public async Task CreateAsync(BookManagement bookManagement) { await _context.BookManagement.AddAsync(bookManagement); await _context.SaveChangesAsync(); }
public BookManagementController() { bookManagement = new BookManagement(); }
public BookController() { _BookManagement = new BookManagement(); }
static void Main(string[] args) { Console.WriteLine("Press any key to continue"); Console.ReadLine(); BookManagement proxy = new BookManagement(); /*OperationResultSetOfUserUcBWdBTS result = proxy.GetAllUsers(); * foreach (User user in result.ResultSet) * { * Console.WriteLine(user.UserName.ToString()); * } * * OperationResultSetOfstring types = proxy.GetAllTypes(); * if (types.Error == OperationResultErrorEnum.None) * { * if (types.ResultSet.Count() > 0) * { * foreach (string type in types.ResultSet) * { * Console.WriteLine(type); * } * } * } * * OperationResultSetOfstring genres = proxy.GetAllGenres(); * if (genres.Error == OperationResultErrorEnum.None) * { * if (genres.ResultSet.Count() > 0) * { * foreach (string genre in genres.ResultSet) * { * Console.WriteLine(genre); * } * } * } * Author author1 = new Author(); * author1.FirstName = "Maria"; * author1.LastName = "Kapon"; * author1.BornDate = new DateTime(1945, 02, 03, 02, 30, 20).ToString(); * author1.DeathDate = new DateTime(2013, 02, 03, 02, 30, 20).ToString(); * OperationResult or = proxy.AddAuthor(author1); * Console.WriteLine("Adding Maria Kapon error" + or.Error.ToString()); * Author author2 = new Author(); * author2.FirstName = "Esra"; * author2.LastName = "Dimitrova"; * author2.BornDate = new DateTime(1937, 04, 03, 02, 30, 20).ToString(); * author2.DeathDate = new DateTime(2012, 05, 03, 02, 30, 20).ToString(); * or = proxy.AddAuthor(author2); * Console.WriteLine("Adding Esra Dimitrova error" + or.Error.ToString()); * Author author3 = new Author(); * author3.FirstName = "Petur"; * author3.LastName = "Marinov"; * author3.BornDate = new DateTime(1925, 04, 03, 02, 30, 20).ToString(); * or = proxy.AddAuthor(author3); * Console.WriteLine("Adding Petur Marinov error" + or.Error.ToString()); * * OperationResultSetOfAuthorUcBWdBTS authors = proxy.GetAllAuthors(); * foreach (Author author in authors.ResultSet) * { * Console.WriteLine(author.AuthorInfo); * } * * /*Book book = new Book(); * book.Author = authors.ResultSet[0]; * book.Genre = "nqma takuv"; * book.Isbn = "1233444"; * book.Title = "One two three"; * book.Type = "nqma takuv"; * User user = new User(); * user.UserName = "******"; * book.User = user; * book.Year = 1988; * OperationResult or1 = proxy.AddBook(book); * Console.WriteLine("Book added " + or1.Error.ToString());*/ User user = new User(); user.UserName = "******"; /*BookOfInterest book = new BookOfInterest(); * book.Title = "D e j"; * book.AuthorName = "Petur Petrov"; * book.User = user; * OperationResult result = proxy.AddBookOfInterest(book); * if (result.Error.Equals(OperationResultErrorEnum.None)) * { * Console.WriteLine("Book successfully added"); * } * else * { * Console.WriteLine(result.ErrorString); * }*/ /*OperationResultSetOfBookOfInterest6WXd3OUP booksOfInterest = proxy.GetAllBooksOfInterestByUser("maria"); * if (booksOfInterest.Error.Equals(OperationResultErrorEnum.None)) * { * foreach (BookOfInterest bookr in booksOfInterest.ResultSet) * { * Console.WriteLine(bookr.Title + " " + bookr.AuthorName + " " + bookr.User.UserName); * } * }*/ OperationResultSetOfBookUcBWdBTS bookcheck = proxy.CheckBookOfInterest(1, true); if (bookcheck.Error.Equals(OperationResultErrorEnum.None)) { foreach (Book bookr in bookcheck.ResultSet) { Console.WriteLine(bookr.Title + " " + bookr.Author.AuthorInfo + " " + bookr.User.UserName); } } Console.WriteLine("Press any key to continue"); Console.Read(); }
private void viewBooks() { BookManagement bookManager = new BookManagement(); bookManager.viewBooks(); }
public async Task DeleteAsync(BookManagement bookManagement) { _context.BookManagement.Remove(bookManagement); await _context.SaveChangesAsync(); }
public async Task UpdateAsync(BookManagement bookManagement) { _context.BookManagement.Update(bookManagement); await _context.SaveChangesAsync(); }
public MainPage() { this.InitializeComponent(); Books = BookManagement.GetBooks(); }