Ejemplo n.º 1
0
        public ActionResult Edit(int actorId)
        {
            var actor = _actorRepository.Get(actorId);

            if (actor == null)
            {
                return new HttpNotFoundResult("Count not find the actor with id " + actorId);
            }

            var actorMovies = _orchardServices.ContentManager.GetMany<MoviePart>(
                    actor.ActorMovies.Select(m => m.MoviePartRecord.Id), VersionOptions.Published, QueryHints.Empty);
            
            var viewModel = new EditActorViewModel{Id = actorId, Name = actor.Name, Movies = actorMovies};

            return View(viewModel);
        }
Ejemplo n.º 2
0
        public ActionResult EditPOST(EditActorViewModel viewModel)
        {
            var actor = _actorRepository.Get(viewModel.Id);

            if (!ModelState.IsValid)
            {
                viewModel.Movies = _orchardServices.ContentManager.GetMany<MoviePart>(actor.ActorMovies.Select(m => m.Id), VersionOptions.Published, QueryHints.Empty);
                return View("Edit", viewModel);
            }

            actor.Name = viewModel.Name;
            _actorRepository.Update(actor);
            _orchardServices.Notifier.Add(NotifyType.Information, T("Saved {0}", viewModel.Name));
            return RedirectToAction("Index");
        }