public ConsentViewModel GetConsentViewModel(string returnUrl, ClientViewModel client,
                                                    IList <ScopeViewModel> scopes,
                                                    IList <IdentityResourceViewModel> identityResources)
        {
            var selectableIdentityResources = m_genericViewModelFactory.GetSelectableViewmodelList(identityResources);

            selectableIdentityResources.ForEach(x => x.IsSelected = x.Item.Required);

            var selectableScopes = m_genericViewModelFactory.GetSelectableViewmodelList(scopes);

            selectableScopes.ForEach(x => x.IsSelected = x.Item.Required);

            var viewModel = new ConsentViewModel
            {
                RememberConsent   = true,
                ReturnUrl         = returnUrl,
                Client            = client,
                IdentityResources = selectableIdentityResources,
                Scopes            = selectableScopes,
            };

            return(viewModel);
        }
        public EditableIdentityResourceViewModel GetEditableIdentityResourceViewModel(
            IList <ClaimTypeViewModel> claimTypes, IdentityResourceViewModel identityResourceViewModel = null)
        {
            var selectableClaimTypes = m_genericViewModelFactory.GetSelectableViewmodelList(claimTypes);

            if (identityResourceViewModel != null)
            {
                selectableClaimTypes.ForEach(claim =>
                                             claim.IsSelected =
                                                 identityResourceViewModel.Claims?.FirstOrDefault(userClaim => userClaim.Id == claim.Item.Id) !=
                                                 null);
            }

            return(new EditableIdentityResourceViewModel
            {
                IdentityResourceViewModel = identityResourceViewModel ?? new IdentityResourceViewModel(),
                SelectableClaimTypes = selectableClaimTypes
            });
        }
Esempio n. 3
0
 public List <SelectableViewModel <T> > GetSelectableViewmodelList <T>(IEnumerable <T> viewModelList)
 {
     return(m_genericViewModelFactory.GetSelectableViewmodelList(viewModelList));
 }