Ejemplo n.º 1
0
        public async Task <IActionResult> AddIdentityProperties(IdentityResourcePropertyDto input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelStateErrors));
            }
            var result = await _identityResourceService.AddIdentityResourcePropertyAsync(input);

            return(ResultResponse(result, "添加身份资源属性成功"));
        }
Ejemplo n.º 2
0
        public async Task <bool> AddIdentityResourcePropertyAsync(IdentityResourcePropertyDto identityResourceProperties)
        {
            var identityResource = await _identityResouceRepository.GetByIdAsync(identityResourceProperties.IdentityResourceId);

            var entity = _mapper.Map <IdentityResourceProperty>(identityResourceProperties);

            entity.IdentityResource = identityResource ?? throw new Exception("IdentityResource不存在");
            await _identityResourcePropertyRepository.AddAsync(entity);

            return(await _identityResourcePropertyRepository.SaveChangesAsync() > 0);
        }
Ejemplo n.º 3
0
        public async Task <bool> CanInsertIdentityResourcePropertyAsync(IdentityResourcePropertyDto property)
        {
            var result = await _identityResourcePropertyRepository.GetAll().FirstOrDefaultAsync(x => x.Key == property.Key && x.IdentityResourceId == property.IdentityResourceId);

            return(result == null);
        }