コード例 #1
0
ファイル: DaoGeographySpec.cs プロジェクト: cramt/QWest
        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();
        }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: DaoGeographySpec.cs プロジェクト: cramt/QWest
        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);
        }
コード例 #4
0
ファイル: EditSubdivision.xaml.cs プロジェクト: cramt/QWest
        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";
        }
コード例 #5
0
ファイル: GeographyController.cs プロジェクト: cramt/QWest
        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));
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public Post(string contents, User userAuthor, Group groupAuthor, DateTime postTime, List <int> images, GeopoliticalLocation locationId)
     : this(contents, userAuthor, groupAuthor, postTime, images, locationId, null)
 {
 }
コード例 #8
0
 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)
 {
 }
コード例 #9
0
 public Task Update(GeopoliticalLocation location)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 public Task <IEnumerable <Subdivision> > GetSubdivisions(GeopoliticalLocation location)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
 public Task <int> Add(GeopoliticalLocation location)
 {
     throw new NotImplementedException();
 }