예제 #1
0
 public BookRisultatiViewModel(Book libro)
 {
     Repository repo = new Repository();
     __book = libro;
     books = repo.FindByTitle(libro.Title).ToList();
     booksAutori = repo.FindByAuthor(libro.Author).ToList();
 }
예제 #2
0
 public void Add_ShouldAddBook()
 {
     var libro = new Book
     {
         Id = ObjectId.Parse("564b0c119028881324c2b115"),
         Title = Title1,
         Author = "gigi l'autore",
         ISBN = "123456789",
         Publisher = "editor"
     };
     _repository.Add(libro);
     Assert.That(true, libro.Title = Title1);
 }
예제 #3
0
        public void FindBooksByAuthor()
        {
            var expectedBook2 = new Book
            {
                Author = Author,
                Title = Title2,
                Publisher = Publisher,
            };

            var books = _repository.FindByAuthor(Author).OrderBy(x => x.Title).ToList();

            Assert.AreEqual(5, books.Count);
            var foundBook = books[0];

            Assert.AreNotSame(_expectedBook, foundBook);

            foundBook = books[1];

            Assert.AreNotSame(expectedBook2, foundBook);
        }
예제 #4
0
 public ActionResult AggiuntaLibro(Book book)
 {
     _repo.Add(book);
     return RedirectToAction("Index");
 }
예제 #5
0
 public ActionResult SalvaModifiche(string id, string titolo, string autore, string isbn, string publisher)
 {
     Book libro = new Book();
     libro.Id = ObjectId.Parse(id);
     libro.Title = titolo;
     libro.Author = autore;
     libro.ISBN = isbn;
     libro.Publisher = publisher;
     _repo.Update(libro);
     return RedirectToAction("Index");
 }
예제 #6
0
 public void Update(Book book)
 {
     mongoColl.Save(book);
 }
예제 #7
0
 public void Add(Book book)
 {
     mongoColl.Insert(book);
 }
예제 #8
0
        public void Setup()
        {
            _expectedBook = new Book
            {
                Author = Author,
                Title = Title1,
                Publisher = Publisher,
                ISBN = Isbn
            };

            _differentBook = new Book
            {
                Author = Author + " Different",
                Title = Title1 + "Different",
                Publisher = (Publisher + "Different"),
                ISBN = Isbn + "Different",
            };

            mongoC = new MongoClient();
            _mongoDatabase = mongoC.GetDatabase("BookMVC");
            mongodb = mongoC.GetServer().GetDatabase("BookMVC");
            mongoColl = mongodb.GetCollection<Book>("BookTest");
            _bookCollection = _mongoDatabase.GetCollection<Book>("BookTest");

            _repository = new Repository(_mongoDatabase);
        }