protected override void ToViewModel() { CategoriaLivro categoria = (CategoriaLivro)Entidades[typeof(CategoriaLivro).Name]; CategoriaLivroModel vm = new CategoriaLivroModel { Id = categoria.Id, Nome = categoria.Nome, Inativo = categoria.Inativo }; _viewModel = vm; }
protected override void ToEntidade() { CategoriaLivroModel vm = (CategoriaLivroModel)ViewModel; CategoriaLivro ctg = new CategoriaLivro { Nome = vm.Nome, Id = vm.Id }; _entidades = new Dictionary <string, object> { [typeof(CategoriaLivro).Name] = ctg }; }
public IActionResult AdicionarCategoria(CategoriaLivroModel categoria) { _vh = new CategoriaLivroViewHelper { ViewModel = categoria }; CategoriaLivro ctgNova = (CategoriaLivro)_vh.Entidades[typeof(CategoriaLivro).Name]; string msg = _facade.Cadastrar(ctgNova); if (!String.IsNullOrEmpty(msg)) { TempData["Alert"] = msg; } return(RedirectToAction(nameof(ConfigLoja))); }