Ejemplo n.º 1
0
        // GET: Author/Edit/5
        public ActionResult Edit(int id)
        {
            var book = _unitOfWork.Books.Get(id);
            var model = new BookAuthorViewModel() {Id = book.Id, Title = book.Title};

            return PartialView("_EditPartial", model);
        }
Ejemplo n.º 2
0
        public ActionResult CreateBook(BookAuthorViewModel model)
        {
            var author = _unitOfWork.Authors.Get(model.AuthorId);
            var book = new Book() {Author = author, Title = model.Title};

            author.Books.Add(book);
            _unitOfWork.SaveChanges();

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, BookAuthorViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Books.Get(id);
                existingRecord.Title = model.Title;

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_EditPartial");
            }
        }
Ejemplo n.º 4
0
        public ActionResult CreateBook(int id)
        {
            var model = new BookAuthorViewModel {AuthorId = id};

            return PartialView("_CreateBookPartial", model);
        }