Example #1
0
        public async Task <bool> AddIdentityResourceAsync(CreateIdentityResourceDto identityResource)
        {
            var apiresource = _mapper.Map <IdentityResource>(identityResource);

            apiresource.Created = DateTime.Now;
            await _identityResouceRepository.AddAsync(apiresource);

            return(await _identityResouceRepository.SaveChangesAsync() > 0);
        }
Example #2
0
        public async Task <IActionResult> UpdateIdentityResource([FromBody] CreateIdentityResourceDto input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelStateErrors));
            }
            var result = await _identityResourceService.UpdateIdentityResourceAsync(input);

            return(ResultResponse(result, "修改身份资源成功"));
        }
Example #3
0
        public async Task <bool> UpdateIdentityResourceAsync(CreateIdentityResourceDto identityResource)
        {
            var entity = await _identityResouceRepository.GetAll().Include(c => c.UserClaims).FirstOrDefaultAsync(d => d.Id == identityResource.Id);

            var apiresource = _mapper.Map <CreateIdentityResourceDto, IdentityResource>(identityResource, entity);

            apiresource.Updated = DateTime.Now;
            _identityResouceRepository.Update(apiresource);
            return(await _identityResouceRepository.SaveChangesAsync() > 0);
        }