Пример #1
0
        public DataResult <int> CreateExternalLogin(
            int userId, string loginProvider, string providerKey
            )
        {
            var externalLoginProviderEntity = m_externalLoginProviderUoW.GetExternalLoginProviderByName(
                loginProvider
                );

            if (externalLoginProviderEntity.DisableManagingByUser)
            {
                const string errorMessage = "Edit this link is not permitted";
                m_logger.LogWarning(errorMessage);
                return(Error <int>(errorMessage));
            }

            var externalLogin = new ExternalLoginEntity
            {
                Provider    = externalLoginProviderEntity,
                ProviderKey = providerKey
            };

            try
            {
                var result = m_userUoW.CreateExternalLogin(userId, externalLogin);
                return(Success(result));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <int>(e.Message));
            }
        }
Пример #2
0
        public DataResult <int> CreateExternalLogin(int userId, ExternalLoginProviderEntity externalLoginProvider, string providerKey)
        {
            var externalLogin = new ExternalLoginEntity
            {
                Provider    = externalLoginProvider,
                ProviderKey = providerKey
            };

            try
            {
                var result = m_userUoW.CreateExternalLogin(userId, externalLogin);
                return(Success(result));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <int>(e.Message));
            }
        }