public async Task <IActionResult> Create(Specialization specialization) { if (ModelState.IsValid) { try { await _specializationRepository.CreateUniqueAsync(specialization); return(RedirectToAction(nameof(Index))); } catch (Exception e) { if (e.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, "A Specialization with that name already exists!"); } else { ModelState.AddModelError(string.Empty, e.InnerException.Message); } } } return(View(specialization)); }