public async Task <ActionResult> UpdateUserPermissions(UpdatePermissionsCommand command) { command.OrganizationId = User.GetOrganizationId(); await _permissionsService.UpdateUserPermissionsAsync(command); return(Ok()); }
public async Task <ActionResult> UpdateUserRole(UpdatePermissionsCommand command) { command.OrganizationId = User.GetOrganizationId(); command.Key = PermissionsHelper.Claims.UserRole; await _permissionsService.UpdateUserPermissionsAsync(command); return(Ok()); }
public UpdatePermissionsCommandHandlerTestsFixture() { RelationshipsRepository = new Mock <IAccountProviderLegalEntitiesRepository>(); Relationships = new List <AccountProviderLegalEntity>(); RelationshipsRepository.SetupInMemoryCollection(Relationships); Handler = new UpdatePermissionsCommandHandler(RelationshipsRepository.Object); Command = new UpdatePermissionsCommand(AccountId, AccountLegalEntityId, AccountProviderId, AccountProviderLegalEntityId, Ukprn, Operations, Updated, UpdateMessageId); }
public async Task <ActionResult> Update(UpdateAccountProviderLegalEntityViewModel model) { var operations = model.Operations.Where(o => o.IsEnabled.HasValue && o.IsEnabled.Value).Select(o => o.Value).ToHashSet(); var command = new UpdatePermissionsCommand(model.AccountId.Value, model.AccountProviderId.Value, model.AccountLegalEntityId.Value, model.UserRef.Value, operations); await _mediator.Send(command); if (Session["Invitation"] as bool? == true) { var provider = await _mediator.Send(new GetAccountProviderQuery(model.AccountId.Value, model.AccountProviderId.Value)); return(Redirect($"{_employerUrls.Account()}/addedprovider/{HttpUtility.UrlEncode(provider.AccountProvider.ProviderName)}")); } return(RedirectToAction("Updated", new UpdatedAccountProviderLegalEntityRouteValues { AccountProviderId = model.AccountProviderId.Value, AccountLegalEntityId = model.AccountLegalEntityId.Value })); }
public UpdatePermissionsCommandHandlerTestsFixture() { Now = DateTime.UtcNow;; UnitOfWorkContext = new UnitOfWorkContext(); Db = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options); Command = new UpdatePermissionsCommand(1, 2, 3, Guid.NewGuid(), new HashSet <Operation> { Operation.CreateCohort }); Account = EntityActivator.CreateInstance <Account>().Set(a => a.Id, Command.AccountId); AccountProvider = EntityActivator.CreateInstance <AccountProvider>().Set(ap => ap.Id, Command.AccountProviderId).Set(ap => ap.AccountId, Account.Id); AccountLegalEntity = EntityActivator.CreateInstance <AccountLegalEntity>().Set(ale => ale.Id, Command.AccountLegalEntityId).Set(ale => ale.AccountId, Account.Id); User = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Command.UserRef); Db.Accounts.Add(Account); Db.AccountProviders.Add(AccountProvider); Db.AccountLegalEntities.Add(AccountLegalEntity); Db.Users.Add(User); Db.SaveChanges(); Handler = new UpdatePermissionsCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db)); }
/// <inheritdoc /> public async Task UpdateUserPermissionsAsync(UpdatePermissionsCommand command) { await _mediator.Send(command); }