public async Task <IHttpActionResult> GetIdentityResourceAsync(string subject)
        {
            if (string.IsNullOrWhiteSpace(subject))
            {
                ModelState["subject.String"].Errors.Clear();
                ModelState.AddModelError("", Messages.SubjectRequired);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.ToError()));
            }

            var result = await _service.GetAsync(subject);

            if (result.IsSuccess)
            {
                if (result.Result == null)
                {
                    return(NotFound());
                }

                var meta = await GetCoreMetaDataAsync();

                return(Ok(new IdentityResourceDetailResource(result.Result, Url, meta)));
            }

            return(BadRequest(result.ToError()));
        }
示例#2
0
        public async Task <ActionResult <IdentityResourceDTO> > GetIdentityResourceAsync(int id)
        {
            var result = await identityResourceService.GetAsync(id);

            return(Ok(result));
        }