public async Task <IActionResult> Edit(int id, Noticia noticia) { if (!ModelState.IsValid) { var autors = await _autorService.FindAllAsync(); var viewModel = new NoticiaFormViewModel { Noticia = noticia, Autors = autors }; return(View(viewModel)); } if (id != noticia.Id) { return(RedirectToAction(nameof(Error), new { message = "Id não correspondem" })); } try { await _noticiaService.UpdateAsync(noticia); return(RedirectToAction(nameof(Index))); } catch (NotFoundException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } catch (DbConcurrencyException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } }