public static IdentityServer4.EntityFramework.Entities.Client ToEntity(this Core.Models.Client client)
        {
            var result = new IdentityServer4.EntityFramework.Entities.Client
            {
                ClientId                     = client.ClientId,
                ClientName                   = client.ClientName,
                Enabled                      = true,
                RequireClientSecret          = true,
                RequireConsent               = true,
                AllowRememberConsent         = true,
                LogoutSessionRequired        = true,
                IdentityTokenLifetime        = 300,
                AccessTokenLifetime          = 3600,
                AuthorizationCodeLifetime    = 300,
                AbsoluteRefreshTokenLifetime = 2592000,
                SlidingRefreshTokenLifetime  = 1296000,
                RefreshTokenUsage            = (int)TokenUsage.OneTimeOnly,
                RefreshTokenExpiration       = (int)TokenExpiration.Absolute,
                EnableLocalLogin             = true,
                PrefixClientClaims           = true,
                AllowAccessTokensViaBrowser  = true,
                LogoUri                      = client.LogoUri,
                ClientUri                    = client.ClientUri,
                AllowedScopes                = client.AllowedScopes == null || !client.AllowedScopes.Any() ? new List <IdentityServer4.EntityFramework.Entities.ClientScope>() : client.AllowedScopes.Select(s => new IdentityServer4.EntityFramework.Entities.ClientScope
                {
                    Scope = s.Name
                }).ToList(),
                RedirectUris = client.RedirectionUrls == null || !client.RedirectionUrls.Any() ? new List <IdentityServer4.EntityFramework.Entities.ClientRedirectUri>() : client.RedirectionUrls.Select(r => new IdentityServer4.EntityFramework.Entities.ClientRedirectUri
                {
                    RedirectUri = r
                }).ToList(),
                ClientSecrets = string.IsNullOrWhiteSpace(client.ClientSecret) ? new List <IdentityServer4.EntityFramework.Entities.ClientSecret>() : new List <IdentityServer4.EntityFramework.Entities.ClientSecret>
                {
                    new IdentityServer4.EntityFramework.Entities.ClientSecret
                    {
                        Value = client.ClientSecret,
                        Type  = "SharedSecret"
                    }
                }
            };

            var grantingMethod = new GrantingMethod
            {
                GrantTypes    = client.GrantTypes,
                ResponseTypes = client.ResponseTypes
            };

            var meth = _mappingIdServerGrantTypesToGrantingMethods.FirstOrDefault(m => m.Value.Equals(grantingMethod));

            if (meth.Equals(default(KeyValuePair <IEnumerable <string>, GrantingMethod>)))
            {
                throw new InvalidOperationException("The grant type is not supported");
            }

            result.AllowedGrantTypes = meth.Key.Select(g => new IdentityServer4.EntityFramework.Entities.ClientGrantType {
                GrantType = g
            }).ToList();
            return(result);
        }
            public bool Equals(GrantingMethod obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                return(Equals((object)obj));
            }