Пример #1
0
        public async Task <IActionResult> Index()
        {
            var listaAutores = await _consultarAutor.ListarTodosAutores();

            var listaAutoresViewModel = AutorFactory.MapearListaAssociadoViewModel(listaAutores);

            return(View(listaAutoresViewModel));
        }
Пример #2
0
        public async Task <IActionResult> Novo(AutorViewModel autorViewModel)
        {
            if (ModelState.IsValid)
            {
                var autor = AutorFactory.MapearAutor(autorViewModel);
                await _criarAutor.Executar(autor);

                return(RedirectToAction("Index"));
            }
            return(View(autorViewModel));
        }
Пример #3
0
        public async Task <IActionResult> Detalhar(int id)
        {
            var autor = await _consultasAutor.BuscarPeloId(id);

            if (autor == null)
            {
                return(RedirectToAction("Index"));
            }

            var autorViewModel = AutorFactory.MapearAutorViewModel(autor);

            return(View(autorViewModel));
        }
Пример #4
0
        public async Task <IActionResult> Alterar(int id, AutorViewModel autorViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(autorViewModel));
            }

            var autor = AutorFactory.MapearAutor(autorViewModel);

            await _alterarAutor.Executar(id, autor);

            return(RedirectToAction("Index"));
        }