public virtual async Task <ApiResourceDto> UpdateAsync(Guid id, ApiResourceCreateUpdateDto input) { var apiResource = await _resourceRepository.GetAsync(id); var existed = await _resourceRepository.CheckNameExistAsync(input.Name, id); if (existed) { throw new UserFriendlyException(L["EntityExisted", nameof(ApiResource), nameof(ApiResource.Name), input.Name]); } apiResource = ObjectMapper.Map(input, apiResource); apiResource.UserClaims.Clear(); input.UserClaims .ForEach(x => apiResource.AddUserClaim(x)); apiResource.Scopes.Clear(); input.Scopes .ForEach(x => apiResource.AddScope(x)); apiResource = await _resourceRepository.UpdateAsync(apiResource); return(ObjectMapper.Map <ApiResource, ApiResourceDto>(apiResource)); }
public async Task Should_Create_Update_Success() { var input = new ApiResourceCreateUpdateDto() { Name = "test", Scopes = new List <string> { "openid", "Age", "NewIdentityResource1" }, UserClaims = new List <string> { "Age" } }; (await _apiResourceAppService.CreateAsync(input)).ShouldNotBeNull(); }
public virtual async Task <ApiResourceDto> CreateAsync(ApiResourceCreateUpdateDto input) { var existed = await _resourceRepository.CheckNameExistAsync(input.Name); if (existed) { throw new UserFriendlyException(L["EntityExisted", nameof(ApiResource), nameof(ApiResource.Name), input.Name]); } var apiResource = new ApiResource(GuidGenerator.Create(), input.Name); apiResource = ObjectMapper.Map(input, apiResource); input.UserClaims.ForEach(x => apiResource.AddUserClaim(x)); input.Scopes.ForEach(x => apiResource.AddScope(x)); apiResource = await _resourceRepository.InsertAsync(apiResource, true); return(ObjectMapper.Map <ApiResource, ApiResourceDto>(apiResource)); }
public virtual Task <ApiResourceDto> UpdateAsync(Guid id, ApiResourceCreateUpdateDto input) { return(_appService.UpdateAsync(id, input)); }
public virtual Task <ApiResourceDto> CreateAsync(ApiResourceCreateUpdateDto input) { return(_appService.CreateAsync(input)); }