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