public async Task <IdentityResourceDto> UpdateAsync(Guid id, UpdateIdentityResourceInputDto input) { var nameExist = await _repository.CheckNameExistAsync(input.Name, id); if (nameExist) { throw new IdentityResourceNameNotAllowedDuplicateException(input.Name); } var identityResource = await _repository.FindAsync(id); identityResource = ObjectMapper.Map <UpdateIdentityResourceInputDto, IdentityResource>(input, identityResource); // userClaim identityResource.RemoveAllUserClaims(); if (input.UserClaims != null) { input.UserClaims.ForEach(e => { identityResource.AddUserClaim(e); }); } identityResource = await _repository.UpdateAsync(identityResource); return(MapToGetOutputDto(identityResource)); }
public async Task <IdentityResourceDto> UpdateAsync(Guid id, UpdateIdentityResourceInputDto input) { var nameExist = await _repository.CheckNameExistAsync(input.Name, id); if (nameExist) { throw new IdentityResourceNameNotAllowedDuplicateException(input.Name); } var identityResource = await _repository.FindAsync(id); identityResource = ObjectMapper.Map <UpdateIdentityResourceInputDto, IdentityResource>(input, identityResource); identityResource = await _repository.UpdateAsync(identityResource); return(MapToGetOutputDto(identityResource)); }
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 async Task <bool> UpdateIdentityResourceAsync(Core.Entities.IdentityResource.IdentityResource identityResource) { return(await _repository.UpdateAsync(identityResource)); }