public async Task Should_Create_Update_Success()
        {
            var input = new IdentityResourceCreateUpdateDto()
            {
                Name       = "test",
                UserClaims = new List <string> {
                    "Age"
                }
            };

            (await _identityResourceAppService.CreateAsync(input)).ShouldNotBeNull();
        }
예제 #2
0
        public virtual async Task <IdentityResourceDto> CreateAsync(IdentityResourceCreateUpdateDto input)
        {
            var existed = await _resourceRepository.CheckNameExistAsync(input.Name);

            if (existed)
            {
                throw new UserFriendlyException(L["EntityExisted", nameof(IdentityResource),
                                                  nameof(IdentityResource.Name),
                                                  input.Name]);
            }

            var identityResource = new IdentityResource(GuidGenerator.Create(), input.Name);

            identityResource = ObjectMapper.Map(input, identityResource);
            input.UserClaims.ForEach(x => identityResource.AddUserClaim(x));

            identityResource = await _resourceRepository.InsertAsync(identityResource, true);

            return(ObjectMapper.Map <IdentityResource, IdentityResourceDto>(identityResource));
        }
예제 #3
0
        public virtual async Task <IdentityResourceDto> UpdateAsync(Guid id,
                                                                    IdentityResourceCreateUpdateDto input)
        {
            var identityResource = await _resourceRepository.GetAsync(id);

            var existed = await _resourceRepository.CheckNameExistAsync(input.Name, id);

            if (existed)
            {
                throw new UserFriendlyException(L["EntityExisted", nameof(IdentityResource),
                                                  nameof(IdentityResource.Name),
                                                  input.Name]);
            }

            identityResource = ObjectMapper.Map(input, identityResource);
            identityResource.UserClaims.Clear();
            input.UserClaims
            .ForEach(x => identityResource.AddUserClaim(x));

            identityResource = await _resourceRepository.UpdateAsync(identityResource);

            return(ObjectMapper.Map <IdentityResource, IdentityResourceDto>(identityResource));
        }
 public virtual Task <IdentityResourceDto> UpdateAsync(Guid id, IdentityResourceCreateUpdateDto input)
 {
     return(_identityResourceAppService.UpdateAsync(id, input));
 }
 public virtual Task <IdentityResourceDto> CreateAsync(IdentityResourceCreateUpdateDto input)
 {
     return(_identityResourceAppService.CreateAsync(input));
 }