public void TearDown() { Utils.CleanUp(true); List <Country> countries = GeopoliticalLocation.Parse(File.ReadAllText(Utilities.Utilities.SolutionLocation + "\\QWest.DataAccess\\res\\geopolitical_location_backup.json")); DAO.Geography.InsertBackup(countries).Wait(); }
public Post(string contents, User userAuthor, Group groupAuthor, DateTime postTime, List <int> images, GeopoliticalLocation locationId, int?id) { Contents = contents; UserAuthor = userAuthor; GroupAuthor = groupAuthor; PostTime = postTime; Images = images; Id = id; Location = locationId; }
public async Task BackUpsCorrectly() { await ConnectionWrapper.Instance.Use("DELETE FROM geopolitical_location", stmt => stmt.ExecuteNonQueryAsync()); List <Country> countries = GeopoliticalLocation.Parse(File.ReadAllText(Utilities.Utilities.SolutionLocation + "\\QWest.DataAccess\\res\\geopolitical_location_backup.json")); await DAO.Geography.InsertBackup(countries); int amount = (await DAO.Geography.FetchEverythingParsed()).Count(); Assert.AreEqual(countries.Count, amount); }
private async Task PopulateAllLocationsListBox() { ParentLocationListBox.Items.Add("Fetching locations..."); AllLocations = GeopoliticalLocation.Traverse(await DAO.Geography.FetchEverythingParsed()).ToList(); DisplayedLocations = new ObservableCollection <GeopoliticalLocation>(AllLocations); ParentLocationListBox.Items.Clear(); Binding parentLocations = new Binding(); parentLocations.Source = DisplayedLocations; ParentLocationListBox.SetBinding(ItemsControl.ItemsSourceProperty, parentLocations); ParentLocationListBox.DisplayMemberPath = "Name"; }
public async Task <ActionResult <GeopoliticalLocation> > Get(string alpha2) { alpha2 = alpha2.ToUpper(); Console.WriteLine(alpha2); GeopoliticalLocation local = await GeographyRepo.GetAnyByAlpha2s(alpha2); if (local == null) { return(NotFound()); } else { return(Ok(local)); } }
private async Task ApplyMigration(SqlConnection conn) { SqlCommand stmt = conn.CreateCommand(); stmt.CommandText = "select schema_version from info"; int schemaVersion = 0; try { schemaVersion = (await stmt.ExecuteReaderAsync()).ToIterator(x => x.GetSqlInt32(0).Value).FirstOrDefault(); } catch (Exception) { stmt = conn.CreateCommand(); stmt.CommandText = "CREATE TABLE info (schema_version INT NOT NULL)"; await stmt.ExecuteNonQueryAsync(); } foreach ((int numeric, string text) in GetScripts().Where(x => x.numeric > schemaVersion)) { stmt = conn.CreateCommand(); stmt.CommandText = text; Console.WriteLine("migrating: " + numeric); await stmt.ExecuteNonQueryAsync(); schemaVersion = numeric; } stmt = conn.CreateCommand(); stmt.CommandText = "delete from info; insert into info (schema_version) values (@schema_version)"; stmt.Parameters.AddWithValue("@schema_version", schemaVersion); await stmt.ExecuteNonQueryAsync(); stmt = conn.CreateCommand(); stmt.CommandText = "SELECT COUNT(*) FROM geopolitical_location"; bool applyGeopoliticalLocationBackup = false; try { applyGeopoliticalLocationBackup = (await stmt.ExecuteReaderAsync()).ToIterator(reader => reader.GetSqlInt32(0).Value == 0).First(); } catch (Exception) { } if (applyGeopoliticalLocationBackup) { List <Country> countries = GeopoliticalLocation.Parse(File.ReadAllText(Utilities.Utilities.SolutionLocation + "\\QWest.DataAccess\\res\\geopolitical_location_backup.json")); await new Mssql.GeographyImpl(null).InsertBackup(countries, conn); } }
public Post(string contents, User userAuthor, Group groupAuthor, DateTime postTime, List <int> images, GeopoliticalLocation locationId) : this(contents, userAuthor, groupAuthor, postTime, images, locationId, null) { }
public Post(string contents, User userAuthor, Group groupAuthor, uint postTime, List <int> images, GeopoliticalLocation locationId, int?id) : this(contents, userAuthor, groupAuthor, postTime.ToDate(), images, locationId, id) { }
public Task Update(GeopoliticalLocation location) { throw new NotImplementedException(); }
public Task <IEnumerable <Subdivision> > GetSubdivisions(GeopoliticalLocation location) { throw new NotImplementedException(); }
public Task <int> Add(GeopoliticalLocation location) { throw new NotImplementedException(); }