public ScopeDetailResource(ScopeDetail scope, UrlHelper url, IdentityAdminMetadata idmAdminMeta) { if (scope == null) throw new ArgumentNullException("scope"); if (url == null) throw new ArgumentNullException("url"); if (idmAdminMeta == null) throw new ArgumentNullException("idmAdminMeta"); Data = new ScopeDetailDataResource(scope, url, idmAdminMeta); var links = new Dictionary<string, string>(); if (idmAdminMeta.ClientMetaData.SupportsDelete) { links["Delete"] = url.Link(Constants.RouteNames.DeleteScope, new { subject = scope.Subject }); } Links = links; }
public Task<IdentityAdminResult<ScopeDetail>> GetScopeAsync(string subject) { int parsedId; if (int.TryParse(subject, out parsedId)) { var inMemoryScope = _scopes.FirstOrDefault(p => p.Id == parsedId); if (inMemoryScope == null) { return Task.FromResult(new IdentityAdminResult<ScopeDetail>((ScopeDetail) null)); } var result = new ScopeDetail { Subject = subject, Name = inMemoryScope.Name, Description = inMemoryScope.Description, }; var metadata = GetMetadata(); var props = from prop in metadata.ScopeMetaData.UpdateProperties select new PropertyValue { Type = prop.Type, Value = GetScopeProperty(prop, inMemoryScope), }; result.Properties = props.ToArray(); result.ScopeClaimValues = new List<ScopeClaimValue>(); Mapper.Map(inMemoryScope.ScopeClaims.ToList(), result.ScopeClaimValues); return Task.FromResult(new IdentityAdminResult<ScopeDetail>(result)); } return Task.FromResult(new IdentityAdminResult<ScopeDetail>((ScopeDetail) null)); }