コード例 #1
0
        public BasicCity[] GetCitiesByCountry(string countryCode)
        {
            BasicCountry country = GetCountry(countryCode);

            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command = GetDbCommand(
                    "SELECT " + cityFieldSequence + " WHERE CountryId=" + country.CountryId,
                    connection);
                List <BasicCity> result = new List <BasicCity>();
                using (DbDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        result.Add(ReadCityFromDataReader(reader));
                        while (reader.Read())
                        {
                            result.Add(ReadCityFromDataReader(reader));
                        }
                    }

                    return(result.ToArray());
                }
            }
        }
コード例 #2
0
ファイル: Person.cs プロジェクト: mikran/Swarmops
        public static Person Create(string name, string email, string password, string phone, string street,
                                    string postal, string city, string countryCode, DateTime dateOfBirth,
                                    PersonGender gender)
        {
            BasicCountry country = null;

            if (countryCode.Length > 0)
            {
                country = Country.FromCode(countryCode);
            }

            // Clean data

            while (name.Contains("  "))
            {
                name = name.Replace("  ", " ");
            }

            name   = name.Trim();
            email  = email.ToLower().Trim();
            phone  = LogicServices.CleanNumber(phone);
            postal = postal.Replace(" ", "").Trim();

            int personId = SwarmDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city,
                                                                        country == null ? 0 : country.Identity, dateOfBirth, gender);


            // Resolve the geography

            Person newPerson = FromIdentityAggressive(personId);

            // aggressive bypasses replication lag, avoids race condition
            newPerson.ResolveGeography();

            // Generate the salted password hash and set it

            if (password.Length > 0)
            {
                newPerson.PasswordHash = Authentication.GenerateNewPasswordHash(personId, password);
            }
            else
            {
                newPerson.PasswordHash = string.Empty; // if no password, prevent matching to anything
            }

            // Return the finished Person object

            return(newPerson);
        }
コード例 #3
0
ファイル: Database-People.cs プロジェクト: JeffreyQ1/Swarmops
        public BasicPerson[] GetPeopleFromPhoneNumber(string countryCode, string phoneNumber)
        {
            BasicCountry country = GetCountry(countryCode);

            return(GetPeopleFromPhoneNumber(country.Identity, phoneNumber));
        }
コード例 #4
0
ファイル: Country.cs プロジェクト: aciofini/Swarmops
 public static Country FromBasic(BasicCountry basic)
 {
     return(new Country(basic));
 }
コード例 #5
0
ファイル: Country.cs プロジェクト: aciofini/Swarmops
 private Country(BasicCountry basic)
     : base(basic)
 {
 }