public async Task <IActionResult> AddBenefit(CreateBenefitViewModel model) { if (this.ModelState.IsValid) { try { await _partnerRepository.AddBenefitAsync(model); return(this.RedirectToAction($"Details/{model.PartnerId}")); } catch (DbUpdateException dbUpdateException) { if (dbUpdateException.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, "There are a record with the same name."); } else { ModelState.AddModelError(string.Empty, dbUpdateException.InnerException.Message); } } catch (Exception exception) { ModelState.AddModelError(string.Empty, exception.Message); } } return(this.View(model)); }