public ActionResult Add()
        {
            var viewModel = new ComicBooksAddViewModel();

            viewModel.Init(Repository, _seriesRepository, _artistsRepository);

            return(View(viewModel));
        }
Exemple #2
0
        public ActionResult Add()
        {
            var viewModel = new ComicBooksAddViewModel();

            viewModel.Init(Context);

            return(View(viewModel));
        }
        public ActionResult Add()
        {
            var viewModel = new ComicBooksAddViewModel();

            viewModel.Init(SeriesRepository, ArtistRepository, RoleRepository);

            return(View(viewModel));
        }
        public ActionResult Add()
        {
            var viewModel = new ComicBooksAddViewModel();

            // TODO Pass the Context class to the view model "Init" method.
            viewModel.Init(Repository, _seriesRepo, _artistRepo);

            return(View(viewModel));
        }
Exemple #5
0
        public ActionResult Add()
        {
            var viewModel = new ComicBooksAddViewModel();

            // TODO Pass the Context class to the view model "Init" method.
            viewModel.Init();

            return(View(viewModel));
        }
        public ActionResult Add(ComicBooksAddViewModel viewModel)
        {
            ValidateComicBook(viewModel.ComicBook);

            if (ModelState.IsValid)
            {
                var comicBook = viewModel.ComicBook;
                comicBook.AddArtist(viewModel.ArtistId, viewModel.RoleId);
                _comicBooksRepository.Add(comicBook);

                TempData["Message"] = "Your comic book was successfully added!";

                return(RedirectToAction("Detail", new { id = comicBook.Id }));
            }

            viewModel.Init(SeriesRepository, ArtistRepository, RoleRepository);

            return(View(viewModel));
        }
        public ActionResult Add(ComicBooksAddViewModel viewModel)
        {
            ValidateComicBook(viewModel.ComicBook);

            if (ModelState.IsValid)
            {
                var comicBook = viewModel.ComicBook;
                comicBook.AddArtist(viewModel.ArtistId, viewModel.RoleId);

                _comicBooksRepository.Add(comicBook);

                TempData["Message"] = "Your comic book was successfully added!";

                return(RedirectToAction("Detail", new { id = comicBook.Id }));
            }

            // TODO Pass the Context class to the view model "Init" method.
            viewModel.Init(Repository, _seriesRepo, _artistRepo);

            return(View(viewModel));
        }
Exemple #8
0
        public ActionResult Add(ComicBooksAddViewModel viewModel)
        {
            ValidateComicBook(viewModel.ComicBook);

            if (ModelState.IsValid)
            {
                var comicBook = viewModel.ComicBook;
                comicBook.AddArtist(viewModel.ArtistId, viewModel.RoleId);

                Context.ComicBooks.Add(comicBook);
                Context.SaveChanges();

                TempData["Message"] = "Your comic book was successfully added!";

                return(RedirectToAction("Detail", new { id = comicBook.Id }));
            }

            viewModel.Init(Context);

            return(View(viewModel));
        }