public IActionResult CreateOrEdit(int id) { ViewBag.ClientId = id; var StandardScopes = typeof(StandardScopes).GetFields(); // ViewBag.GrantType =Newtonsoft.Json.JsonConvert.SerializeObject( gt.GetFields().Select(X => new { name = X.Name, value = X.GetValue(gt).ToString() }).ToList()); var StandardScopes2Api = new List <IdentityServer4.EntityFramework.Entities.ApiScope>(); foreach (var StandardScope in StandardScopes) { StandardScopes2Api.Add(new IdentityServer4.EntityFramework.Entities.ApiScope() { Name = StandardScope.GetValue(StandardScopes).ToString(), DisplayName = StandardScope.Name }); } StandardScopes2Api.AddRange(_configurationDbContext.ApiScopes); ViewBag.Scopes = ((StandardScopes2Api)); return(View()); }
public async Task <MessageModel <ApiResourceDto> > GetDataById(int id = 0) { var model = (await _configurationDbContext.ApiResources .Include(d => d.UserClaims).Include(d => d.Scopes) .ToListAsync()).FirstOrDefault(d => d.Id == id).ToModel(); var StandardScopess = typeof(StandardScopes).GetFields(); // ViewBag.GrantType =Newtonsoft.Json.JsonConvert.SerializeObject( gt.GetFields().Select(X => new { name = X.Name, value = X.GetValue(gt).ToString() }).ToList()); var StandardScopes2Api = new List <IdentityServer4.EntityFramework.Entities.ApiScope>(); foreach (var StandardScope in StandardScopess) { StandardScopes2Api.Add(new IdentityServer4.EntityFramework.Entities.ApiScope() { Name = StandardScope.GetValue(StandardScopess).ToString(), DisplayName = StandardScope.Name }); } if (_configurationDbContext.ApiScopes.Count() > 0) { StandardScopes2Api.AddRange(_configurationDbContext.ApiScopes); } var apiResourceDto = new ApiResourceDto(); if (model != null) { apiResourceDto = new ApiResourceDto() { Name = model?.Name, DisplayName = model?.DisplayName, Description = model?.Description, UserClaims = string.Join(",", model?.UserClaims), Scopes = string.Join(",", model?.Scopes), StandardScopes = StandardScopes2Api.Select(X => new { id = X.Name, text = X.DisplayName }) }; } apiResourceDto.StandardScopes = StandardScopes2Api.Select(X => new { id = X.Name, text = X.DisplayName }); return(new MessageModel <ApiResourceDto>() { success = true, msg = "获取成功", response = apiResourceDto }); }