private ScopeViewModel CreateScopeViewModel(IdentityResource identity, UserModel user, bool check) { var scopeViewModel = new ScopeViewModel { Name = identity.Name, DisplayName = identity.DisplayName, Description = identity.Description, Emphasize = identity.Emphasize, Required = identity.Required, Checked = check || identity.Required }; if (scopeViewModel.Name.Equals("profile", StringComparison.OrdinalIgnoreCase)) { var descriptionSB = new StringBuilder("Personal Info: Given Name, Family Name, Username, Email"); foreach (var attribute in user.CustomAttributes) { descriptionSB.Append(", ").Append(attribute.Key); } scopeViewModel.Description = descriptionSB.ToString(); } return(scopeViewModel); }
public WorkflowCollectionViewModel(ScopeViewModel currentScope, ServiceContext context) : base(currentScope) { this.currentScope = currentScope; this.context = context; this.Workflows = new ObservableCollection <WorkflowViewModel>(); }
public static ScopeViewModel GetOfflineAccessScope(this ScopeViewModel model, bool check) { model.Name = IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess; model.DisplayName = ConsentOptions.OfflineAccessDisplayName; model.Description = ConsentOptions.OfflineAccessDescription; model.Emphasize = true; model.Checked = check; return(model); }
public async Task <string> CreateAsync(ScopeViewModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var param = ToParam(model); return(await _service.CreateAsync(param)); }
private ScopeViewModel CreateScopeViewModel(IdentityResource identityResource, bool isChecked) { ScopeViewModel scopeViewModel = new ScopeViewModel() { Checked = identityResource.Required || isChecked, Required = identityResource.Required, Description = identityResource.Description, DisplayName = identityResource.DisplayName, Emphasize = identityResource.Emphasize, Name = identityResource.Name }; return(scopeViewModel); }
private ScopeViewModel CreateScopeViewModel(Scope scope, bool isChecked) { ScopeViewModel scopeViewModel = new ScopeViewModel() { Checked = scope.Required || isChecked, Required = scope.Required, Description = scope.Description, DisplayName = scope.DisplayName, Emphasize = scope.Emphasize, Name = scope.Name }; return(scopeViewModel); }
public async Task <IActionResult> CreateAsync([FromBody] ScopeViewModel model) { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _service.CreateAsync(model); return(Created($"scopes/{result}", result)); }
public async Task UpdateAsync(ScopeViewModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (string.IsNullOrWhiteSpace(model.Id)) { throw new InvalidOperationException(nameof(model.Id)); } var param = ToParam(model); await _service.UpdateAsync(param); }
public async Task <IActionResult> UpdateAsync([FromBody] ScopeViewModel model) { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _service.UpdateAsync(model); return(NoContent()); }
public async Task <ActionResult> RegisterScope(ScopeViewModel scopeViewModel) { ActionResult Result = Ok(); IdentityServer4.Models.ApiScope Scope = new IdentityServer4.Models.ApiScope { Name = scopeViewModel.Name, DisplayName = scopeViewModel.DisplayName }; bool IsSuccess = await Repository.AddApiScope(Scope); if (!IsSuccess) { Result = Problem("Error to add scope", null, 500, "", null); } return(Result); }
public EditableScopeViewModel GetEditableScopeViewModel(int apiResourceId, IList <ClaimTypeViewModel> claimTypes, ScopeViewModel scope = null) { var selectableClaimTypes = m_genericViewModelFactory.GetSelectableViewmodelList(claimTypes); if (scope != null) { selectableClaimTypes.ForEach(claim => claim.IsSelected = scope.Claims?.FirstOrDefault(userClaim => userClaim.Id == claim.Item.Id) != null); } return(new EditableScopeViewModel { ApiResourceId = apiResourceId, SelectableClaimTypes = selectableClaimTypes }); }
// GET: Admin/Home/Delete public async Task <ActionResult> Delete(string name) { var adminStore = new IdentityServer3AdminStore(); var scope = await adminStore.FindScopeByNameAsync(name); if (scope == null) { return(RedirectToAction("Index")); } ScopeViewModel model = new ScopeViewModel { Name = scope.Name, Description = scope.Description, ScopeType = scope.Type }; return(View(model)); }
public IActionResult ChangeOrganisationScope(string encryptedOrganisationId, int reportingYear) { long organisationId = DecryptOrganisationId(encryptedOrganisationId); // Check user has permissions to access this page ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId); // Get Organisation and OrganisationScope for reporting year Organisation organisation = dataRepository.Get <Organisation>(organisationId); OrganisationScope organisationScope = organisation.GetScopeForYear(reportingYear); var viewModel = new ScopeViewModel { Organisation = organisation, ReportingYear = organisationScope.SnapshotDate, IsToSetInScope = !organisationScope.IsInScopeVariant() }; return(View(organisationScope.IsInScopeVariant() ? "OutOfScopeQuestions" : "ConfirmScope", viewModel)); }
public async Task <ActionResult> Delete(ScopeViewModel model) { try { Scope scope = new Scope { Name = model.Name }; var adminStore = new IdentityServer3AdminStore(); await adminStore.DeleteScopeAsync(scope); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task UpdateAsync_WithInvalidModel_ReturnsBadRequest() { // Arrange var controller = GetController(); var model = new ScopeViewModel { // Name // required }; // ModelState must be manually adjusted controller.ModelState.AddModelError(string.Empty, "Name required!"); // Act var result = await controller.UpdateAsync(model); // Assert Assert.NotNull(result); Assert.IsType <BadRequestObjectResult>(result); }
private void CreateConsentViewModel(string returnUrl, AuthorizationRequest request, Client client, Resources resources) { // on First load, create an object instance // otherwise, created by asp.net mvc form if (Input == null) { Input = new ConsentInputModel(); } this.ClientName = client.ClientName ?? client.ClientId; this.ClientUrl = client.ClientUri; this.ClientLogoUrl = client.LogoUri; this.AllowRememberConsent = client.AllowRememberConsent; Input.RememberConsent = true; Input.ReturnUrl = returnUrl; Input.IdentityScopes = resources.IdentityResources .Select(x => CreateScopeViewModel(x)).ToList(); Input.ResourceScopes = resources.ApiResources .SelectMany(x => x.Scopes) .Select(x => CreateScopeViewModel(x)).ToList(); if (ConsentOptions.EnableOfflineAccess && resources.OfflineAccess) { if (Input.ResourceScopes == null) { Input.ResourceScopes = new List <ScopeViewModel>(); } var offlineScope = GetOfflineAccessScope(true); var scopeviemodels = new ScopeViewModel[] { offlineScope }; Input.ResourceScopes = Input.ResourceScopes.Union(scopeviemodels).ToList(); } }
private ScopeViewModel CreateScopeViewModel(Resource resource, bool isEdit, bool enabled) { var vm = new ScopeViewModel { Description = resource.Description, DisplayName = resource.DisplayName, Enabled = isEdit? enabled : resource.Enabled, Name = resource.Name, }; if (resource is IdentityResource) { vm.Required = (resource as IdentityResource).Required; vm.Emphasize = (resource as IdentityResource).Emphasize; } if (resource is ApiScope) { vm.Required = (resource as ApiScope).Required; vm.Emphasize = (resource as ApiScope).Emphasize; } return(vm); }
public ScopeView() { InitializeComponent(); // needed? OnSizeAllocated(Width, Height); // ScopeView has numerous View <--> ViewModel interactions, so grab // a handle to the ViewModel svm = (ScopeViewModel)BindingContext; // Give the ScopeViewModel an ability to display "toast" messages on // the View (such as "saved foo.csv") by having the View monitor for // notifications, and if one is received // https://stackoverflow.com/a/26038700/11615696 svm.notifyToast += (string msg) => Util.toast(msg, scrollOptions); svm.theChart = chart; // since the ramanModeEnabled switch is not "bound" to the ViewModel, // we must manually process PropertyChange notifications svm.PropertyChanged += viewModelPropertyChanged; }
public EditableScopeViewModel GetEditableScopeViewModel(int apiResourceId, IList <ClaimTypeViewModel> claimTypes, ScopeViewModel scope = null) { return(m_editableViewModelFactory.GetEditableScopeViewModel(apiResourceId, claimTypes, scope)); }
private static ScopeParam ToParam(ScopeViewModel model) => SimpleMapper.From <ScopeViewModel, ScopeParam>(model);
public IActionResult ConfirmInScopeAnswers(string encryptedOrganisationId, int reportingYear, ScopeViewModel viewModel) { long organisationId = DecryptOrganisationId(encryptedOrganisationId); // Check user has permissions to access this page ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId); // Get Organisation and OrganisationScope for reporting year Organisation organisation = dataRepository.Get <Organisation>(organisationId); DateTime currentSnapshotDate = organisation.SectorType.GetAccountingStartDate(); RetireOldScopes(organisation, reportingYear); UpdateScopes(organisation, ScopeStatuses.InScope, reportingYear, null, null); dataRepository.SaveChanges(); SendScopeChangeEmails(organisation, viewModel.ReportingYear, currentSnapshotDate, ScopeStatuses.InScope); return(RedirectToAction("ScopeDeclared", "Organisation", new { id = encryptedOrganisationId })); }
public IActionResult SubmitOutOfScopeAnswers(string encryptedOrganisationId, int reportingYear, ScopeViewModel viewModel) { long organisationId = DecryptOrganisationId(encryptedOrganisationId); // Check user has permissions to access this page ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId); viewModel.ParseAndValidateParameters(Request, m => m.WhyOutOfScope); viewModel.ParseAndValidateParameters(Request, m => m.HaveReadGuidance); if (viewModel.WhyOutOfScope == WhyOutOfScope.Other) { viewModel.ParseAndValidateParameters(Request, m => m.WhyOutOfScopeDetails); } // Get Organisation and OrganisationScope for reporting year Organisation organisation = dataRepository.Get <Organisation>(organisationId); OrganisationScope organisationScope = organisation.OrganisationScopes.FirstOrDefault(s => s.SnapshotDate.Year == reportingYear); viewModel.Organisation = organisation; viewModel.ReportingYear = organisationScope.SnapshotDate; viewModel.IsToSetInScope = false; if (viewModel.HasAnyErrors()) { return(View("OutOfScopeQuestions", viewModel)); } return(View("ConfirmScope", viewModel)); }
public IActionResult ConfirmOutOfScopeAnswers(string encryptedOrganisationId, int reportingYear, ScopeViewModel viewModel) { long organisationId = DecryptOrganisationId(encryptedOrganisationId); // Check user has permissions to access this page ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId); // Get Organisation Organisation organisation = dataRepository.Get <Organisation>(organisationId); // Update OrganisationScope var reasonForChange = viewModel.WhyOutOfScope == WhyOutOfScope.Under250 ? "Under250" : viewModel.WhyOutOfScopeDetails; DateTime currentSnapshotDate = organisation.SectorType.GetAccountingStartDate(); RetireOldScopes(organisation, reportingYear); UpdateScopes(organisation, ScopeStatuses.OutOfScope, reportingYear, reasonForChange, viewModel.HaveReadGuidance == HaveReadGuidance.Yes); dataRepository.SaveChanges(); SendScopeChangeEmails(organisation, viewModel.ReportingYear, currentSnapshotDate, ScopeStatuses.OutOfScope); OrganisationScope organisationScope = organisation.OrganisationScopes.FirstOrDefault(s => s.SnapshotDate.Year == reportingYear); viewModel.Organisation = organisation; viewModel.ReportingYear = organisationScope.SnapshotDate; return(View("FinishOutOfScopeJourney", viewModel)); }
public void NavigateToWorkflowsSummaryPage(ScopeViewModel selectedScope) { this.NavigateToPage(new WorkflowsSummaryPage(), selectedScope); }
public void NavigateToActivitiesSummaryPage(ScopeViewModel selectedScope) { this.NavigateToPage(new ActivitiesSummaryPage(), selectedScope); }
public void NavigateToScope(ScopeViewModel scope) { this.NavigateToPage(new ScopeDetailsPage(), scope); }