Ejemplo n.º 1
0
        public ActionResult Edit(long? id)
        {
            EditBookViewModel view = new EditBookViewModel()
            {
                Book = _service.GetBook(id ?? 0),
                Categories = _service.GetCategories()
            };

            return View(view);
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            EditBookViewModel view = new EditBookViewModel()
            {
                Book = new BookModel(),
                Categories = _service.GetCategories()
            };

            return View("edit", view);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(BookModel model)
        {
            if (ModelState.IsValid)
            {
                long id = _service.SaveBook(model);

                return RedirectToAction("view", "book", new
                {
                    id = id
                });
            }

            EditBookViewModel view = new EditBookViewModel()
            {
                Book = model,
                Categories = _service.GetCategories()
            };

            return View(view);
        }