public ActionResult Create(Agenda agenda) { try { if (ModelState.IsValid) { agenda.EmpresaID = Convert.ToInt32(User.FindFirst(ClaimTypes.GroupSid).Value); AgendaService service = new AgendaService(); service.PreencherCampos(agenda); _agenda.Inserir(agenda); return(RedirectToAction(nameof(Index))); } return(View(agenda)); } catch (Exception ex) { Mensagem = ex.Message.ToString(); ModelState.AddModelError(String.Empty, Mensagem); return(View(agenda)); } }