コード例 #1
0
ファイル: DataAccess.cs プロジェクト: slitz/cid
        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);
        }
コード例 #2
0
ファイル: DataAccess.cs プロジェクト: slitz/cid
        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);
        }