public async Task <IActionResult> Edit(int id, Objective obj) { if (ModelState.IsValid) { try { await _objectiveService.UpdateAsync(obj); TempData["confirm"] = obj.Name + " foi editado com sucesso."; list = await _objectiveService.FindAllAsync(); _cache.Set("objective", list, cacheOptions); return(RedirectToAction(nameof(Index))); } catch (ApplicationException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } } if (id != obj.Id) { return(RedirectToAction(nameof(Error), new { message = "Id's não correspondem" })); } TempData["erro"] = "Erro ao editar."; return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, Objective obj) { if (id != obj.Id) { return(NotFound()); } if (ModelState.IsValid) { await _objectiveService.UpdateAsync(obj); return(RedirectToRoute(new { controller = "Curriculums", action = "Details", id = TempData["id"] })); } return(View(obj)); }