public ActionResult Create(ModelGroup.Book book)
        {
            if (ModelState.IsValid)
            {
                context.Books.Add(book);
                context.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(book);
        }
        public ActionResult Edit(int id, ModelGroup.Book book)
        {
            ModelGroup.Book _book = context.Books.Single(p => p.BookID == id);

            if (ModelState.IsValid)
            {
                _book.BookName = book.BookName;
                _book.ISBN = book.ISBN;

                context.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(book);
        }
        public ActionResult Create(ModelGroup.Review review)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ModelGroup.Book book = context.Books.SingleOrDefault(b => b.BookID == review.BookID);
                    book.Reviews.Add(review);
                    context.SaveChanges();

                    return RedirectToAction("Details", "Books", new {id = book.BookID});
                }

                return View();
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Delete(int id, ModelGroup.Book book)
        {
            ModelGroup.Book _book = context.Books.Single(p => p.BookID == id);
            context.Books.Remove(_book);
            context.SaveChanges();

            return RedirectToAction("Index");
        }
Exemple #5
0
 public void AddNewGroup(string groupName, IHandModel leftModel, IHandModel rightModel) {
   ModelGroup newGroup = new ModelGroup();
   newGroup.LeftModel = leftModel;
   newGroup.RightModel = rightModel;
   newGroup.GroupName = groupName;
   newGroup.CanDuplicate = false;
   newGroup.IsEnabled = true;
   ModelPool.Add(newGroup);
 }