public ActionResult Create(EditableApiAccessKeyViewModel editableViewModel) { if (ModelState.IsValid) { var selectedPermissions = GetSelectedItems(editableViewModel.SelectableApiPermissions).Select(x => (ApiAccessPermissionEnumModel)x); var apiAccessKeyModel = Mapper.Map <ApiAccessKeyModel>(editableViewModel); apiAccessKeyModel.ApiKeyHash = m_hashManager.GenerateHash(editableViewModel.EditableApiAccessKeyHashViewModel.Value, editableViewModel.EditableApiAccessKeyHashViewModel.Algorithm); var result = m_apiAccessKeyManager.CreateApiAccessKey(apiAccessKeyModel, selectedPermissions); if (!result.HasError) { return(RedirectToAction(nameof(View), new { id = result.Result })); } ModelState.AddModelError(result.Error.Message); } var vm = ViewModelBuilder.BuildApiAccessKeyViewModel(ModelState, editableViewModel); return(View(vm)); }