public static ClientModel FromEntity(IdentityServer4.EntityFramework.Entities.Client client)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <IdentityServer4.Models.Client, ClientModel>());
            var mapper = config.CreateMapper();
            var model  = mapper.Map <ClientModel>(client.ToModel());

            model.Id = client.Id;
            return(model);
        }
Example #2
0
        private SharedModels.Client MapDaltoBll(IdentityServer4.EntityFramework.Entities.Client clientModel)
        {
            IdentityServer4.Models.Client clientModelIds4 = new IdentityServer4.Models.Client();
            clientModelIds4 = clientModel.ToModel();

            SharedModels.Client client = new SharedModels.Client();
            client.ClientId              = clientModelIds4.ClientId;
            client.ClientName            = clientModelIds4.ClientName;
            client.ClientUri             = clientModelIds4.ClientUri;
            client.FrontChannelLogoutUrl = clientModelIds4.FrontChannelLogoutUri;

            if (clientModelIds4.ClientSecrets.Count > 0)
            {
                foreach (IdentityServer4.Models.Secret secret in clientModelIds4.ClientSecrets)
                {
                    client.ClientSecret = secret.Value;
                }
            }

            if (clientModelIds4.AllowedGrantTypes.Count > 0)
            {
                foreach (string grantType in clientModelIds4.AllowedGrantTypes)
                {
                    client.GrantType = grantType;
                }
            }

            if (clientModelIds4.Properties.Count > 0)
            {
                foreach (var property in clientModelIds4.Properties)
                {
                    client.ClientProperty = property.Value;
                }
            }

            if (clientModelIds4.RedirectUris.Count > 0)
            {
                client.RedirectUrls = new string[clientModel.RedirectUris.Count];
                int i = 0;
                foreach (string uri in clientModelIds4.RedirectUris)
                {
                    client.RedirectUrls[i] = uri;
                    i++;
                }
            }

            if (clientModelIds4.PostLogoutRedirectUris.Count > 0)
            {
                foreach (string uri in clientModelIds4.PostLogoutRedirectUris)
                {
                    client.PostLogoutUrl = uri;
                }
            }

            if (clientModelIds4.AllowedScopes.Count > 0)
            {
                client.AllowedScopes = new string[clientModel.AllowedScopes.Count];
                int i = 0;
                foreach (string scope in clientModelIds4.AllowedScopes)
                {
                    client.AllowedScopes[i] = scope;
                    i++;
                }
            }
            return(client);
        }