public async Task <IActionResult> CreateSection(Section model) { if (ModelState.IsValid) { if (await _repository.SectionExistsAsync(model.Name)) { ModelState.AddModelError("Section Exists", _stringLocalizer["A section with that name already exists"].ToString()); } else { model.LastModifiedByName = User.Identity.Name; int result = await _repository.AddSectionAsync(model); if (result < 1) { TempData["SectionMessage"] = _stringLocalizer["Failed to create"].ToString(); } else { TempData["SectionMessage"] = _stringLocalizer["Section created successfully"].ToString(); } return(RedirectToAction(nameof(Index))); } } ViewBag.Title = _stringLocalizer["Create Section"].ToString(); return(View(model)); }