/// <summary> /// Deprecated Method for adding a new object to the Configurations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToConfigurations(Configuration configuration) { base.AddObject("Configurations", configuration); }
/// <summary> /// Create a new Configuration object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="simulationStartDate">Initial value of the SimulationStartDate property.</param> /// <param name="simulationEndDate">Initial value of the SimulationEndDate property.</param> /// <param name="personDemandsPerDay">Initial value of the PersonDemandsPerDay property.</param> /// <param name="creditCardBalanceMin">Initial value of the CreditCardBalanceMin property.</param> /// <param name="creditCardBalanceMax">Initial value of the CreditCardBalanceMax property.</param> /// <param name="creditCardLimitMin">Initial value of the CreditCardLimitMin property.</param> /// <param name="creditCardLimitMax">Initial value of the CreditCardLimitMax property.</param> /// <param name="transactionValueMin">Initial value of the TransactionValueMin property.</param> /// <param name="transactionValueMax">Initial value of the TransactionValueMax property.</param> public static Configuration CreateConfiguration(global::System.Int32 id, global::System.String name, global::System.DateTime simulationStartDate, global::System.DateTime simulationEndDate, global::System.Double personDemandsPerDay, global::System.Int32 creditCardBalanceMin, global::System.Int32 creditCardBalanceMax, global::System.Int32 creditCardLimitMin, global::System.Int32 creditCardLimitMax, global::System.Int32 transactionValueMin, global::System.Int32 transactionValueMax) { Configuration configuration = new Configuration(); configuration.Id = id; configuration.Name = name; configuration.SimulationStartDate = simulationStartDate; configuration.SimulationEndDate = simulationEndDate; configuration.PersonDemandsPerDay = personDemandsPerDay; configuration.CreditCardBalanceMin = creditCardBalanceMin; configuration.CreditCardBalanceMax = creditCardBalanceMax; configuration.CreditCardLimitMin = creditCardLimitMin; configuration.CreditCardLimitMax = creditCardLimitMax; configuration.TransactionValueMin = transactionValueMin; configuration.TransactionValueMax = transactionValueMax; return configuration; }
public static bool SaveConfiguration(ConfigurationData data) { using (var ctx = new CityContainer()) { var configurationExists = ctx.Configurations.Any(c => c.Name == data.ConfigurationName); if (configurationExists) return false; var poiTypes = ctx.PoiTypes.Where(t => data.PoiTypes.Contains(t.Code)); var newConfiguration = new Configuration { Name = data.ConfigurationName, SelectionMethod = ctx.SelectionMethods.Single(m => m.Name == data.SimulationMethodName), SimulationStartDate = data.SimulationStartDate, SimulationEndDate = data.SimulationEndDate, PersonDemandsPerDay = data.DemandsPerPersonPerDay, CreditCardBalanceMin = data.CreditCardBalanceMin, CreditCardBalanceMax = data.CreditCardBalanceMax, CreditCardLimitMin = data.CreditCardLimitMin, CreditCardLimitMax = data.CreditCardLimitMax, TransactionValueMin = data.TransactionValueMin, TransactionValueMax = data.TransactionValueMax }; // Assign POI circle areas foreach (var circleAreaObject in data.CircleAreas) { newConfiguration.CircleAreas.Add(new CircleArea { Configuration = newConfiguration, Lat = circleAreaObject.Pushpin.Location.Latitude, Lng = circleAreaObject.Pushpin.Location.Longitude, Range = circleAreaObject.Range }); } // Assign POI types for configuration foreach (var poiType in poiTypes) newConfiguration.PoiTypes.Add(poiType); // Assign Districts for configuration foreach (var polygon in data.Polygons) { var district = new District { Configuration = newConfiguration, Population = polygon.Population, Name = polygon.DistrictName }; foreach (var location in polygon.Locations) { district.MapPoints.Add(new MapPoint { Lat = location.Latitude, Lng = location.Longitude }); } } ctx.Configurations.AddObject(newConfiguration); ctx.SaveChanges(); return true; } }