Ejemplo n.º 1
0
        public async Task Role_Updated_Distributed_Event_Test()
        {
            var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"));

            var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync("R", role.Name);

            permissionGrantsInRole.ShouldNotBeNull();
            permissionGrantsInRole.Count.ShouldBeGreaterThan(0);
            var count = permissionGrantsInRole.Count;

            using (var uow = UowManager.Begin())
            {
                var identityResult = await RoleManager.SetRoleNameAsync(role, "TestModerator");

                identityResult.Succeeded.ShouldBeTrue();
                await RoleRepository.UpdateAsync(role);

                await uow.CompleteAsync();
            }

            role = await RoleRepository.GetAsync(role.Id);

            role.Name.ShouldBe("TestModerator");

            permissionGrantsInRole = await PermissionGrantRepository.GetListAsync("R", role.Name);

            permissionGrantsInRole.Count.ShouldBe(count);
        }
Ejemplo n.º 2
0
        public async Task SetRoleNameAsync()
        {
            var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));

            role.ShouldNotBeNull();

            (await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue();

            role.Name.ShouldBe("teacher");
        }
Ejemplo n.º 3
0
        public async Task <IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
        {
            var role = await _roleManager.GetByIdAsync(id);

            (await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors();

            (await _roleManager.UpdateAsync(role)).CheckErrors();
            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <IdentityRole, IdentityRoleDto>(role));
        }
Ejemplo n.º 4
0
        public virtual async Task <IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
        {
            var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false);

            role.ConcurrencyStamp = input.ConcurrencyStamp;

            (await _roleManager.SetRoleNameAsync(role, input.Name).ConfigureAwait(false)).CheckErrors();

            role.IsDefault = input.IsDefault;
            role.IsPublic  = input.IsPublic;

            (await _roleManager.UpdateAsync(role).ConfigureAwait(false)).CheckErrors();
            await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);

            return(ObjectMapper.Map <IdentityRole, IdentityRoleDto>(role));
        }