public int AddConfiguration(int indicatorid, Configuration config)
 {
     using (ConfigurationDAO.Connection = ConnectionSettings.CreateDBConnection())
     {
         return ConfigurationDAO.AddConfiguration(indicatorid, config);
     }
 }
 public int AddConfiguration(int indicatorId, Configuration config)
 {
     return DbTemplateHelper<int>.GetValueByProcedure(
         Connection,
         "config.addconfiguration",
         new DbParameterHelper[]
         {
             new DbParameterHelper(DbType.String,    "p_geolevel",       config.GeoLevel),
             new DbParameterHelper(DbType.Int32,     "p_shapefileid",    config.Shapefile.ID),
             new DbParameterHelper(DbType.Int32,     "p_indicatorid",    indicatorId)
         });
 }
Example #3
0
        public static void addConfiguration(DbConnection conn, Indicator indicator, string lowestGeoLevel)
        {
            var configurationDAO = new ConfigurationDAO(conn);
            for (int geoLevel = int.Parse(lowestGeoLevel); geoLevel >= 2; --geoLevel)
            {
                GEOLevels level = (GEOLevels)geoLevel;

                Console.WriteLine("... Adding configuration: {0} ....", level.ToString());

                DataStore.Common.Model.Configuration config = new DataStore.Common.Model.Configuration
                {
                    GeoLevel = level.ToString(),
                    Shapefile = new Shapefile
                    {
                        ID = SHAPEFILE_IDS[level]
                    }
                };
                configurationDAO.AddConfiguration(indicator.ID, config);
            }
        }
        public void GetConfigurationTest()
        {
            ConfigurationDAO target = new ConfigurationDAO(connnetion);

            int indicatorId = 1;
            string geoLevel = "NUTS1";
            Configuration expected = new Configuration
            {
                ID = 1,
                GeoLevel = "NUTS1",
                Shapefile = new Shapefile
                {
                    ID = 4,
                    FileName = "nuts1.shp",
                    Name = "NUTS1",
                    Path = "D:\\Dropbox\\My Dropbox\\Tese\\shapefiles\\sapo\\GIS\\NUTS1",
                    Level = 1
                }
            };

            Configuration actual;
            actual = target.GetConfiguration(indicatorId, geoLevel);

            Assert.AreEqual(expected, actual);
        }