Example #1
0
        public SpotifyApi()
        {
            var spotifyCredentials = new SecretContainer("spotify");

            _baseUri         = new Uri("https://api.spotify.com");
            _clientID        = spotifyCredentials.ClientId;
            _clientSecret    = spotifyCredentials.ClientSecret;
            _client          = new HttpClient();
            _clientByteArray = new UTF8Encoding().GetBytes($"{_clientID}:{_clientSecret}");
            GetToken();
            _client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_token.Access_token}");
            _client.DefaultRequestHeaders.Add("Accept", "application/json");
        }
Example #2
0
 public Settings(EnvironmentEnum environment)
 {
     Environment = environment;
     if (Environment == EnvironmentEnum.Local)
     {
         RebuildDatabase  = true;
         ConnectionString = @"Data Source=(localdb)\mssqllocaldb;Initial Catalog=ScoreCard;User id=launchpad;Password=mcquack123!;";
     }
     else if (Environment == EnvironmentEnum.Production)
     {
         RebuildDatabase = false;
         var secretContainer             = new SecretContainer("scoreCard_db");
         var connectionStringCredentials = $"User Id={secretContainer.UserName};Password={ secretContainer.Password};";
         ConnectionString = @"Data Source=SQL6003.site4now.net;Initial Catalog=DB_A2AF2E_scorecard;" + connectionStringCredentials;
     }
 }
Example #3
0
        public SpotifyApi()
        {
            var spotifyCredentials = new SecretContainer("spotify");

            _secretContainer = new SecretContainer("brollop_mail");
            _baseUri         = new Uri("https://api.spotify.com");
            _clientID        = spotifyCredentials.ClientId;
            _clientSecret    = spotifyCredentials.ClientSecret;
            _client          = new HttpClient();
            _client.DefaultRequestHeaders.Add("Accept", "application/json");
            Queue           = new List <Track>();
            LandingListSize = 4;
            TakeFromQueue   = true;
            LandingPlaylist = new List <Track>();
            BasicPlaylistId = "0cWW0sr3Hu48SFdtdCcP6K";
            GetTokensFromDatabase();
        }
        private static ISession OpenSession()
        {
            var  dbCredentials = new SecretContainer("brollop_db");
            bool doesDBExist   = false;
            //var constr = ConfigurationManager.ConnectionStrings["MyDbConn"].ToString();
            var password = new SecureString();

            foreach (char character in dbCredentials.Password)
            {
                password.AppendChar(character);
            }
            password.MakeReadOnly();
            var credentials = new SqlCredential(dbCredentials.UserName, password);

            using (SqlConnection con = new SqlConnection(ConnectionString, credentials))
            {
                using (SqlCommand com = new SqlCommand($"select name from sys.databases where name = '{Databasename}';", con))
                {
                    con.Open();
                    //con.Open();
                    SqlDataReader reader = com.ExecuteReader();
                    if (reader.Read())
                    {
                        doesDBExist = true;
                    }
                    reader.Close();
                }
            }
            if (doesDBExist)

            {
                if (_sessionFactory == null)
                {
                    _sessionFactory = Configure().BuildSessionFactory();
                }
                ISession session = _sessionFactory.OpenSession();
                session.BeginTransaction();
                return(session);
            }
            else
            {
                return(null);
            }
        }
        public static Configuration Configure()
        {
            var           dbCredentials = new SecretContainer("brollop_db");
            Configuration cfg           = new Configuration()
                                          .DataBaseIntegration(db =>
            {
                //db.ConnectionString = ConnectionString + " Trusted_Connection = True;";
                db.ConnectionString = ConnectionString + $"User Id={dbCredentials.UserName};Password={dbCredentials.Password};";               // + " Trusted_Connection = True;";
                db.Dialect <MsSql2008Dialect>();
            });

            var mapper = new ModelMapper();

            Type[] myTypes = Assembly.GetExecutingAssembly().GetExportedTypes();
            mapper.AddMappings(myTypes);

            HbmMapping mapping = new DataBase.Mapping.Mapping().Map();

            cfg.AddMapping(mapping);

            return(cfg);
        }
 public PersonController()
 {
     _secretContainer = new SecretContainer("brollop_mail");
 }