public async Task <IActionResult> Edit(long?id, Agenda agenda) { if (id != agenda.Id) { return(NotFound()); } if (id != null) { try { agenda.IdUser = userManager.GetUserAsync(User).Result.Id; await agendaDAL.GravarAgenda(agenda); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("Index")); } return(View(agenda)); }