Beispiel #1
0
        public long AddChargingStationData(string postalCode, int chargingStationCount, int portCount)
        {
            long result = 0;

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    charging_station_data entity = new charging_station_data()
                    {
                        postal_code   = postalCode,
                        station_count = chargingStationCount,
                        port_count    = portCount,
                        date          = DateTime.Now
                    };

                    dbContext.charging_station_data.Add(entity);

                    if (dbContext.SaveChanges() > 0)
                    {
                        result = entity.id;
                    }
                }
                catch (Exception ex)
                {
                    result = 0;
                    string.Format("Unable to add charging station data: {0}.", ex);
                }
            }

            return(result);
        }
Beispiel #2
0
 public app_config GetAppConfig(long id)
 {
     using (CIDEntities dbContext = new CIDEntities())
     {
         app_config entity = dbContext.app_config.FirstOrDefault(row => row.id == id);
         return(entity);
     }
 }
Beispiel #3
0
        public location GetLocationByPostalCode(string postalCode)
        {
            location entity = new location();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    entity = dbContext.locations.FirstOrDefault(row => row.postal_code == postalCode);
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve location by postal code: {0}", postalCode);
                }
            }

            return(entity);
        }
Beispiel #4
0
        public metropolitan_area GetMetropolitanAreaById(Int32 id)
        {
            metropolitan_area entity = new metropolitan_area();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    entity = dbContext.metropolitan_area.FirstOrDefault(row => row.id == id);
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve metropolitan area by id: {0}", id);
                }
            }

            return(entity);
        }
Beispiel #5
0
        public state GetStateByStateCode(string code)
        {
            state entity = new state();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    entity = dbContext.states.FirstOrDefault(row => row.state_cd == code);
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve state by code: {0}", code);
                }
            }

            return(entity);
        }
Beispiel #6
0
        public List <app_config> GetAppConfigs()
        {
            var list = new List <app_config>();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    list = dbContext.app_config.ToList();
                }
                catch
                {
                    string.Format("unable to retrieve app_config records");
                }
            }

            return(list);
        }
Beispiel #7
0
        public List <metropolitan_area> GetAllMetropolitanAreas()
        {
            var list = new List <metropolitan_area>();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    var query = from m in dbContext.metropolitan_area
                                select m;

                    list = query.ToList();
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve metropolitan areas");
                }
            }

            return(list);
        }
Beispiel #8
0
        public bool UpdateAppConfig(string name, string value)
        {
            bool result = true;

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    app_config entity = dbContext.app_config.FirstOrDefault(row => row.name == name);
                    entity.value = value;

                    dbContext.SaveChanges();
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve app_config by name: {0}", name);
                }
            }

            return(result);
        }
Beispiel #9
0
        public List <location> GetLocationsByMetropolitanAreaId(Int32 metroAreaId)
        {
            var list = new List <location>();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    var query = from l in dbContext.locations
                                where l.metropolitan_area_id == metroAreaId
                                select l;

                    list = query.ToList();
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve locations by metropolitan area id: {0}", metroAreaId);
                }
            }

            return(list);
        }
Beispiel #10
0
        public List <charging_station_data> GetChargingStationDataByPostalCode(string postal_code)
        {
            var list = new List <charging_station_data>();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    var query = from c in dbContext.charging_station_data
                                where c.postal_code == postal_code
                                select c;

                    list = query.ToList();
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve charging station data by postal code: {0}", postal_code);
                }
            }

            return(list);
        }
Beispiel #11
0
        public List <location> GetLocationsByState(string state)
        {
            var list = new List <location>();

            using (CIDEntities dbContext = new CIDEntities())
            {
                try
                {
                    var query = from l in dbContext.locations
                                where l.state == state
                                select l;

                    list = query.ToList();
                }
                catch (Exception)
                {
                    string.Format("unable to retrieve locations by state name: {0}", state);
                }
            }

            return(list);
        }