public async Task <IActionResult> IdentityResource(IdentityResourceDto identityResource)
        {
            if (!ModelState.IsValid)
            {
                return(View(identityResource));
            }

            identityResource = _identityResourceService.BuildIdentityResourceViewModel(identityResource);

            int identityResourceId;

            if (identityResource.Id == 0)
            {
                identityResourceId = await _identityResourceService.AddIdentityResourceAsync(identityResource);
            }
            else
            {
                identityResourceId = identityResource.Id;
                await _identityResourceService.UpdateIdentityResourceAsync(identityResource);
            }

            SuccessNotification(string.Format(_localizer["SuccessAddIdentityResource"], identityResource.Name), _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(IdentityResource), new { Id = identityResourceId }));
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] IdentityResourceApiDto identityResourceApi)
        {
            var identityResourceDto = identityResourceApi.ToIdentityResourceApiModel <IdentityResourceDto>();
            await _identityResourceService.AddIdentityResourceAsync(identityResourceDto);

            return(Ok());
        }
Example #3
0
        public async Task <IActionResult> IdentityResource(IdentityResourceDto identityResource)
        {
            if (!ModelState.IsValid)
            {
                return(Success(identityResource));
            }

            identityResource = _identityResourceService.BuildIdentityResourceViewModel(identityResource);

            int identityResourceId;

            if (identityResource.Id == 0)
            {
                identityResourceId = await _identityResourceService.AddIdentityResourceAsync(identityResource);
            }
            else
            {
                identityResourceId = identityResource.Id;
                await _identityResourceService.UpdateIdentityResourceAsync(identityResource);
            }



            return(Success(new { Id = identityResourceId }));
        }
Example #4
0
        public async Task <IActionResult> CreateIdentityResource([FromBody] CreateIdentityResourceDto input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelStateErrors));
            }
            var result = await _identityResourceService.AddIdentityResourceAsync(input);

            return(ResultResponse(result, "创建身份资源成功"));
        }
        public async Task <IActionResult> New([FromBody] IdentityResource resource)
        {
            if (!IsValidResource(resource))
            {
                return(Error());
            }

            var success = await _service.AddIdentityResourceAsync(resource);

            if (success)
            {
                return(Success());
            }
            return(Error());
        }
Example #6
0
        public async Task <ActionResult <IdentityResourceDTO> > CreateIdentityResourceAsync([FromBody] IdentityResourceDTO dto)
        {
            var result = await identityResourceService.AddIdentityResourceAsync(dto);

            return(Ok(result));
        }