public IActionResult AddSecret(int apiResourceId, EditableSecretViewModel secret) { if (!ModelState.IsValid) { var viewModel = ViewModelBuilder.BuildAddSecretViewModel(ModelState, apiResourceId, secret); return(View(viewModel)); } var secretModel = Mapper.Map <SecretModel>(secret); var result = m_secretManager.AddSecretToApiResource(apiResourceId, secretModel); if (result.HasError) { ModelState.AddModelError(result.Error.Message); var viewModel = ViewModelBuilder.BuildAddSecretViewModel(ModelState, apiResourceId, secret); return(View(viewModel)); } return(RedirectToAction(nameof(Secrets), new { apiResourceId })); }