Beispiel #1
0
        public void ConnectToAddBookAndDeleteBook()
        {
            List <Book> NewBook = _data.GetBookPassThru();

            DateTime today           = new DateTime(2021, 04, 29);
            Book     addingInProcess = new Book();

            addingInProcess.Description    = "text";
            addingInProcess.Price          = 3.00M;
            addingInProcess.Title          = "Book Name";
            addingInProcess.PublishDate    = today;
            addingInProcess.IsPaperback    = false;
            addingInProcess.AuthorID_FK    = 1;
            addingInProcess.GenreID_FK     = 1;
            addingInProcess.PublisherID_FK = 1;

            _data.CreateBookPassThru(addingInProcess);

            List <Book> OldBook = _data.GetBookPassThru();
            int         NB      = NewBook.Count;
            int         OB      = OldBook.Count;

            Assert.AreEqual(OB, NB + 1);
            //cleanup
            //foreach (var i in OldBook)
            //{
            //    if (i.Title == "Book Name")
            //    {
            //        addingInProcess.BookID = i.BookID;
            //    }
            //}
            //_data.DeleteBookPassThru(addingInProcess);
        }
        public ActionResult CreateBook(BookVM b) // Convert from string, ints, datetime etc... instead of BookVM b
        {
            if (!ModelState.IsValid)
            {
                ViewBagsForCreateAndUpdate();
                return(View(b));
            }

            Book newBookLC = BookMapper.ConvertBookVMToBook(b);

            bookLogic.CreateBookPassThru(newBookLC);

            return(RedirectToAction("GetBooks", "Book"));
        }