public ActionResult Create([FromForm] Competencia model) { if (ModelState.IsValid) { try { _competenciaRepository.Insert(model); return(RedirectToAction(nameof(Index))); } catch (AggregateException ae) when(ae.InnerException != null && ae.InnerException is HttpRequestException) { ViewBag.ErrorMessage = ae.InnerException.Message; } } return(View(model)); }