Example #1
0
 public DBConnection(string connectionType)
 {
     RegisterInterface();
     //dBConnetion = unityContainer.Resolve<IDBConnection>(connectionType);
     dBConnetion = unityContainer.Resolve <IDBConnection>(connectionType);
     returnValue = dBConnetion.Connect();
 }
Example #2
0
    static DatabaseConnection()
    {
        var myConnectionString =         // get your connection string;
                                 ActiveConnection = new SqlConnection(myConnectionString);

        ActiveConnection.Connect();         // This is bad, really should be in a using
    }
        public EmployeeResponse RetrieveEmployeeMetrics(string email)
        {
            using (IServiceScope scope = ServiceProvider.CreateScope())
            {
                IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>();
                dbConnection.Connect();

                var result = dbConnection.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereEmail(email));

                return(result.Any() ? new EmployeeResponse(result.First()) : null);
            }
        }
        public EttEmployee RetrieveEmployeeInfo(string email)
        {
            using (IServiceScope scope = ServiceProvider.CreateScope())
            {
                IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>();
                dbConnection.Connect();
                var query  = QueryGenerator.GetEmployeeInfo(email);
                var result = dbConnection.ExecuteQuery <EttEmployee>(query);

                return(result.Any() ? result.First() : null);
            }
        }
Example #5
0
        public int InsertRows(string table, List <dynamic> rows)
        {
            int dbResponse = 0;

            using (IServiceScope scope = ServiceProvider.CreateScope())
            {
                IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>();
                dbConnection.Connect();
                string insertStatement = CreateInsertStatement(table, rows);
                dbResponse = dbConnection.ExecuteNonQuery(insertStatement);
            }
            return(dbResponse);
        }
        public List <EmployeeResponse> RetrieveAllEmployeeMetrics()
        {
            using (IServiceScope scope = ServiceProvider.CreateScope())
            {
                IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>();
                dbConnection.Connect();

                var results       = dbConnection.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereRole("Developer"));
                var castedResults = new List <EmployeeResponse>();
                foreach (var res in results)
                {
                    castedResults.Add(new EmployeeResponse(res));
                }
                return(castedResults.Any() ? castedResults : null);
            }
        }
Example #7
0
 public void Connect()
 {
     db.Connect();
 }