protected void UpdateData(int IdCity) { int IDCity = IdCity; NostradamusGeoContextFactory factory = new NostradamusGeoContextFactory(); using (var context = factory.CreateDbContext(new string[] { Constants.ConnectionGeoLocal })) { try { var data = context.Cities.Where(x => x.Id == IDCity).FirstOrDefault(); var state = context.StateRegions.Where(x => x.Id == data.RegionState).FirstOrDefault(); var country = context.Countries.Where(x => x.Id == data.Country).FirstOrDefault(); var TZ = context.TimeZoneLists.Where(x => x.Idtzone == data.TimeZone).FirstOrDefault(); Data = ModelsTransformer.TransferModel <City, MCityData>(data); Data.StateRegionData = ModelsTransformer.TransferModel <StateRegion, MStateRegionData>(state); Data.CountryData = ModelsTransformer.TransferModel <Country, MCountryData>(country); Data.TimeZoneData = ModelsTransformer.TransferModel <TimeZoneList, MTimeZoneData>(TZ); } catch (Exception ex) { LogMaster lm = new LogMaster(); lm.SetLog($"MCityDataHelper ->UpdateData-> {ex.Message}"); } } }
protected void GetData(bool withItemselect) { NostradamusGeoContextFactory factory = new NostradamusGeoContextFactory(); using (var context = factory.CreateDbContext(new string[] { Constants.ConnectionGeoLocal })) { try { var data = context.StateRegions.Where(x => x.CountryRef == IDCountry).OrderBy(x => x.StateRegion1).ToList(); Data = ModelsTransformer.TransferModelList <StateRegion, MStateRegionData>(data); if (withItemselect) { MStateRegionData mdata = new MStateRegionData() { Acronym = "NO", CountryRef = 0, Id = 0, StateRegion1 = "Please select..." }; Data.Insert(0, mdata); } } catch (Exception ex) { LogMaster lm = new LogMaster(); lm.SetLog(ex.Message); } } }
protected void GetData() { NostradamusGeoContextFactory factory = new NostradamusGeoContextFactory(); using (var context = factory.CreateDbContext(new string[] { Constants.ConnectionGeoLocal })) { try { var data = context.Countries.OrderBy(x => x.CountryName).ToList(); Data = ModelsTransformer.TransferModelList <Country, MCountryData>(data); } catch (Exception ex) { LogMaster lm = new LogMaster(); lm.SetLog(ex.Message); } } }