Beispiel #1
0
        public IActionResult AddScope(int apiResourceId, EditableScopeViewModel scope)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = ViewModelBuilder.BuildAddScopeViewModel(ModelState, apiResourceId);

                return(View(viewModel));
            }

            var claimsIds  = GetSelectedItems(scope.SelectableClaimTypes).Select(x => x.Id);
            var scopeModel = Mapper.Map <ScopeModel>(scope);

            var result = m_scopeManager.AddScopeToApiResource(apiResourceId, scopeModel, claimsIds);

            if (result.HasError)
            {
                ModelState.AddModelError(result.Error.Message);

                var viewModel = ViewModelBuilder.BuildAddScopeViewModel(ModelState, apiResourceId);

                return(View(viewModel));
            }

            return(RedirectToAction(nameof(Scopes), new { apiResourceId }));
        }
Beispiel #2
0
        public IActionResult AddScope(int apiResourceId)
        {
            var viewModel = ViewModelBuilder.BuildAddScopeViewModel(ModelState, apiResourceId);

            return(View(viewModel));
        }