public ActionResult Editar(FilmeViewModel viewModel) { if (ModelState.IsValid) { try { var filme = Mapper.Map <Filme>(viewModel); _filmeService.Update(filme); return(RedirectToAction("Index")); } catch (Exception ex) { throw; } } return(View(viewModel)); }
public ActionResult Edit(int id, FormCollection collection) { try { if (ModelState.IsValid) { var entity = _service.Get(id); entity.Nome = collection["Nome"].ToString(); entity.Ano = int.Parse(collection["Ano"].ToString()); var genero = collection["Genero"]; entity.Genero = genero.Split(new char[] { ',' }).ToList(); _service.Update(entity); } return(RedirectToAction("Index")); } catch { return(View()); } }