Пример #1
0
        public ActionResult Create([Bind(Include = "BookISBN,BookTitle,AuthorName,Genre,GenreType")] Book book)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (db.Books.Any(b => b.BookTitle == book.BookTitle))
                    {
                        ModelState.AddModelError("", "Unable to create this Book. These Book Title already exists");
                    }
                    else
                    {
                        db.Books.Add(book);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (DuplicateNameException)
            {
                ModelState.AddModelError("", "Unable to save changes. These Book Details already exist");
            }
            //ViewBag.BookName = new ChoiceList(db.Books, "BookISBN", "BookTitle", "AuthorName");


            return(View(book));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "BookClubID,BookClubName,AdminEmail,Profile,Status,Province,County,Area,LibraryID,NextMeeting,CurrentRead")] BookClub bookClub)
        {
            if (ModelState.IsValid)
            {
                db.BookClubs.Add(bookClub);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LibraryID = new SelectList(db.Libraries, "LibraryID", "LibraryName", bookClub.LibraryID);
            return(View(bookClub));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "BookListID,BookListName,BookListType,BookListContent,BookClubID")] BookList bookList)
        {
            if (ModelState.IsValid)
            {
                db.BookLists.Add(bookList);
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = bookList.BookListID }));
            }
            ViewBag.BookClubID = bookList.BookClubID;

            return(View(bookList));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "BookISBN,Rating,Comment")] Review review)
        {
            if (ModelState.IsValid)
            {
                review.UserID = User.Identity.GetUserId();
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Details", "Book", new { id = review.BookISBN }));
            }

            //  ViewBag.BookTitle = new SelectList(db.Books, "BookISBN", "AuthorName", review.BookISBN);
            return(View(review));
        }