public ActionResult Edit(AtorModelView ator) { try { if (!ModelState.IsValid) { atorService.Update(Mapper.Map <AtorModelView, Ator>(ator)); return(RedirectToAction("Index")); } return(RedirectToAction("Edit", ator)); } catch (Exception e) { ViewBag.Erro = e.Message; return(View(ator)); } }
public ActionResult AddAtuacaoSerie(AtorModelView ator, string serieId) { var getAtorComObjCorreto = _atorService.GetById(ator.Id); try { if (!ModelState.IsValid) { var idVindoDoViewBagDaSerie = _filmeService.GetById(serieId.AsInt()); getAtorComObjCorreto.AtorFilmes.Add(idVindoDoViewBagDaSerie); atorService.Update(getAtorComObjCorreto); return(RedirectToAction("Index")); } return(RedirectToAction("Create")); } catch (Exception E) { ViewBag.Erro = E.Message; ViewBag.Atores = Mapper.Map <ICollection <Ator>, ICollection <AtorModelView> >(_atorService.GetAll()); return(View(Mapper.Map <Ator, AtorModelView>(getAtorComObjCorreto))); } }