Пример #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (CountryId != null)
         {
             hashCode = hashCode * 59 + CountryId.GetHashCode();
         }
         if (NewCountryId != null)
         {
             hashCode = hashCode * 59 + NewCountryId.GetHashCode();
         }
         if (IsPrimary != null)
         {
             hashCode = hashCode * 59 + IsPrimary.GetHashCode();
         }
         if (SessionToken != null)
         {
             hashCode = hashCode * 59 + SessionToken.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #2
0
        public bool Equals(ConventionInfoDto other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Id.Equals(other.Id) &&
                   RequestId.Equals(other.RequestId) &&
                   CountryId.Equals(other.CountryId) &&
                   EarlyRegTypeId.Equals(other.EarlyRegTypeId) &&
                   string.Equals((string)RegNumberInternationalApp, (string)other.RegNumberInternationalApp) &&
                   string.Equals((string)PublishRegNumberInternationalApp,
                                 (string)other.PublishRegNumberInternationalApp) &&
                   string.Equals((string)RegNumberEurasianApp, (string)other.RegNumberEurasianApp) &&
                   string.Equals((string)PublishRegNumberEurasianApp, (string)other.PublishRegNumberEurasianApp) &&
                   string.Equals((string)HeadIps, (string)other.HeadIps) &&
                   Object.Equals(DateInternationalApp, other.DateInternationalApp) &&
                   Object.Equals(PublishDateInternationalApp, other.PublishDateInternationalApp) &&
                   Object.Equals(DateEurasianApp, other.DateEurasianApp) &&
                   Object.Equals(PublishDateEurasianApp, other.PublishDateEurasianApp) &&
                   Object.Equals(InternationalAppToNationalPhaseTransferDate,
                                 other.InternationalAppToNationalPhaseTransferDate) &&
                   Object.Equals(TermNationalPhaseFirsChapter, other.TermNationalPhaseFirsChapter) &&
                   Object.Equals(TermNationalPhaseSecondChapter, other.TermNationalPhaseSecondChapter));
        }
Пример #3
0
        public async Task ChangeCountry(Location location, CountryId countryId)
        {
            var modLocation = await _context.Locations.FindAsync(location.Id);

            modLocation.UpdateCountry(await GetCountryAsync(countryId));
            await _context.SaveChangesAsync();
        }
Пример #4
0
 public override string GetCacheKey()
 {
     return(string.Format("CityCriteria_{0}_{1}_{2}",
                          CountryId == null ? "null" : CountryId.GetCacheKey(),
                          ZipCode == null ? "null" : ZipCode.GetCacheKey(),
                          Id == null ? "null" : Id.GetCacheKey()));
 }
Пример #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (AccountPaid != false)
            {
                hash ^= AccountPaid.GetHashCode();
            }
            if (CountryId != 0)
            {
                hash ^= CountryId.GetHashCode();
            }
            if (BattleTag.Length != 0)
            {
                hash ^= BattleTag.GetHashCode();
            }
            if (ManualReview != false)
            {
                hash ^= ManualReview.GetHashCode();
            }
            if (identity_ != null)
            {
                hash ^= Identity.GetHashCode();
            }
            if (AccountMuted != false)
            {
                hash ^= AccountMuted.GetHashCode();
            }
            return(hash);
        }
Пример #6
0
        /// <summary>
        /// Returns true if CitizenshipModel2 instances are equal
        /// </summary>
        /// <param name="other">Instance of CitizenshipModel2 to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CitizenshipModel2 other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CountryId == other.CountryId ||
                     CountryId != null &&
                     CountryId.Equals(other.CountryId)
                     ) &&
                 (
                     NewCountryId == other.NewCountryId ||
                     NewCountryId != null &&
                     NewCountryId.Equals(other.NewCountryId)
                 ) &&
                 (
                     IsPrimary == other.IsPrimary ||
                     IsPrimary != null &&
                     IsPrimary.Equals(other.IsPrimary)
                 ) &&
                 (
                     SessionToken == other.SessionToken ||
                     SessionToken != null &&
                     SessionToken.Equals(other.SessionToken)
                 ));
        }
Пример #7
0
        public void Country_created()
        {
            var countryId = new CountryId(SequentialGuid.NewSequentialGuid());
            var sut       = Country.Create(countryId, "Dystopia");

            Assert.NotNull(sut);
            Assert.Contains("Dystopia", sut.Name);
        }
Пример #8
0
        public static async Task <bool> CheckIfCountryExists(CountryId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new CountryRepository(context);

            return(await repository.ExistsAsync(id));
        }
Пример #9
0
        /// <summary>
        /// Returns true if PhysicalAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of PhysicalAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PhysicalAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CountryId == other.CountryId ||
                     CountryId != null &&
                     CountryId.Equals(other.CountryId)
                     ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     AdministrativeArea == other.AdministrativeArea ||
                     AdministrativeArea != null &&
                     AdministrativeArea.Equals(other.AdministrativeArea)
                 ) &&
                 (
                     DependentLocality == other.DependentLocality ||
                     DependentLocality != null &&
                     DependentLocality.Equals(other.DependentLocality)
                 ) &&
                 (
                     SortingCode == other.SortingCode ||
                     SortingCode != null &&
                     SortingCode.Equals(other.SortingCode)
                 ) &&
                 (
                     Organization == other.Organization ||
                     Organization != null &&
                     Organization.Equals(other.Organization)
                 ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ));
        }
Пример #10
0
        public override int GetHashCode()
        {
            var hashCode = -1769064886;

            hashCode = hashCode * -1521134295 + CountryId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            return(hashCode);
        }
Пример #11
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Nickname != null)
         {
             hashCode = hashCode * 59 + Nickname.GetHashCode();
         }
         if (CountryId != null)
         {
             hashCode = hashCode * 59 + CountryId.GetHashCode();
         }
         if (Zip != null)
         {
             hashCode = hashCode * 59 + Zip.GetHashCode();
         }
         if (City != null)
         {
             hashCode = hashCode * 59 + City.GetHashCode();
         }
         if (AdministrativeArea != null)
         {
             hashCode = hashCode * 59 + AdministrativeArea.GetHashCode();
         }
         if (DependentLocality != null)
         {
             hashCode = hashCode * 59 + DependentLocality.GetHashCode();
         }
         if (SortingCode != null)
         {
             hashCode = hashCode * 59 + SortingCode.GetHashCode();
         }
         if (Organization != null)
         {
             hashCode = hashCode * 59 + Organization.GetHashCode();
         }
         if (AddressLine1 != null)
         {
             hashCode = hashCode * 59 + AddressLine1.GetHashCode();
         }
         if (AddressLine2 != null)
         {
             hashCode = hashCode * 59 + AddressLine2.GetHashCode();
         }
         if (IsPrimary != null)
         {
             hashCode = hashCode * 59 + IsPrimary.GetHashCode();
         }
         if (SessionToken != null)
         {
             hashCode = hashCode * 59 + SessionToken.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #12
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ CountryId.GetHashCode();
         return(hashCode);
     }
 }
Пример #13
0
        public override int GetHashCode()
        {
            var hashCode = -1615181142;

            hashCode = hashCode * -1521134295 + ProvinceId.GetHashCode();
            hashCode = hashCode * -1521134295 + CountryId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            return(hashCode);
        }
Пример #14
0
        public override bool Equals(object obj)
        {
            var other = obj as CountryInfo;

            if (other == null)
            {
                return(false);
            }

            return(CountryId.Equals(other.CountryId));
        }
Пример #15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Code != null ? Code.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CountryId.GetHashCode();
         hashCode = (hashCode * 397) ^ Id.GetHashCode();
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #16
0
        public static async Task RemoveCountry(CountryId id)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new CountryRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new CountryService(repository, unitOfWork);
            var countryController = new CountryController(service);

            var updateCommand = new Commands.DeleteCountry
            {
                Id = id
            };

            await countryController.DeleteCountry(updateCommand);
        }
Пример #17
0
        /// <summary>
        /// Assigns a key to the city, if it is filled.
        /// </summary>
        private void GenerateCityId()
        {
            string baseKey;

            if (CityName.HasValue())
            {
                baseKey = CountryId.ToString();
                if (StateId.HasValue)
                {
                    baseKey += StateId.Value.ToString();
                }
                baseKey += CityName;

                CityId = baseKey.ToMD5HashString();
            }
        }
Пример #18
0
        public static CountryId GetCountryFromPostal(string code, CountryId eCountryDef = CountryId.ANY)
        {
            // Is this a valid PostalCode for a country ? USA, Canada

            // http://stackoverflow.com/questions/578406/what-is-the-ultimate-postal-code-and-zip-regex

            // "US"=>"^\d{5}([\-]?\d{4})?$",
            // "UK"=>"^(GIR|[A-Z]\d[A-Z\d]??|[A-Z]{2}\d[A-Z\d]??)[ ]??(\d[A-Z]{2})$",
            // "DE"=>"\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b",
            // "CA"=>"^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$",
            // "FR"=>"^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$",
            // "IT"=>"^(V-|I-)?[0-9]{5}$",
            // "AU"=>"^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$",
            // "NL"=>"^[1-9][0-9]{3}\s?([a-zA-Z]{2})?$",
            // "ES"=>"^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$",
            // "DK"=>"^([D-d][K-k])?( |-)?[1-9]{1}[0-9]{3}$",
            // "SE"=>"^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$",
            // "BE"=>"^[1-9]{1}[0-9]{3}$"

            if (Regex.IsMatch(code, @"^\d{5}(-\d{4})?$"))
            {
                return(CountryId.USA);
            }

            if (Regex.IsMatch(code, @"^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$")) // pass="******", fail="5367|||425611|||31 545"
            {
                return(CountryId.SWE);
            }

            // Canada
            // Lower case letters are not strictly allowed. but we allow them.
            if (Regex.IsMatch(code, @"^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}$"))
            {
                return(CountryId.CAN);
            }

            // Australian postal code verification.
            // Australia has 4-digit numeric postal codes with the following state based specific ranges. ACT: 0200-0299 and 2600-2639. NSW: 1000-1999, 2000-2599 and 2640-2914. NT: 0900-0999 and 0800-0899. QLD: 9000-9999 and 4000-4999. SA: 5000-5999. TAS: 7800-7999 and 7000-7499. VIC: 8000-8999 and 3000-3999. WA: 6800-6999 and 6000-6799
            if (Regex.IsMatch(code, @"^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$"))
            {
                return(CountryId.AUS);
            }

            // Look for bad chars or bad length that no valid zip would use?
            return(CountryId.ANY);   // no idea what country this might be.
        }
Пример #19
0
        public static async Task UpdateCountryName(CountryId id, string name)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new CountryRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new CountryService(repository, unitOfWork);
            var countryController = new CountryController(service);

            var updateCommand = new Commands.SetCountryName
            {
                Id   = id,
                Name = name
            };

            await countryController.Put(updateCommand);
        }
Пример #20
0
        //private IEnumerable<Product> GetProducts(Func<Product, bool> condition)
        //{
        //    if (Products == null)
        //    {
        //        return null;
        //    }
        //    return Products.Where(condition);
        //}

        public int?GetDistance(string destCountryCode, string destCity, string destSuburb)
        {
            if (string.IsNullOrEmpty(destCountryCode) || string.IsNullOrEmpty(destCity) ||
                string.IsNullOrEmpty(destSuburb))
            {
                return(null);
            }

            if (!CountryId.Equals(destCountryCode) || !City.Equals(destCity))
            {
                return(null);
            }

            if (Suburb.Equals(destSuburb))
            {
                return(0);
            }

            return(SuburbDistance.GetDistance(CountryId, City, Suburb, destCountryCode, destCity, destSuburb));
        }
Пример #21
0
        /// <summary>
        /// Assigns a key to the composeykey, to avoid duplicity.
        /// </summary>
        private void GenerateComposeKey()
        {
            string baseKey = CountryId.ToString();

            if (StateId.HasValue)
            {
                baseKey += StateId.Value.ToString();
            }

            if (CityId.HasValue())
            {
                baseKey += CityId;
            }

            baseKey += HolidayDate.Year.ToString();
            baseKey += HolidayDate.Month.ToString();
            baseKey += HolidayDate.Day.ToString();
            baseKey += HolidayType.Key.ToString();
            baseKey += NativeDescription;

            ComposeKey = baseKey.ToMD5HashString();
        }
Пример #22
0
        public void Country_not_created(CountryId id, string name)
        {
            Action sut = () => Country.Create(id, name);

            Assert.Throws <ArgumentNullException>(sut.Invoke);
        }
Пример #23
0
 /// <summary>
 /// Get country with specified id.
 /// </summary>
 /// <param name="userContext">User context.</param>
 /// <param name="countryId">Requested country id</param>
 /// <returns>Country with specified id.</returns>
 public virtual ICountry GetCountry(IUserContext userContext,
                                    CountryId countryId)
 {
     return(GetCountries(userContext).Get(countryId));
 }
Пример #24
0
 public void SignedUp(SignUpId id, UserId ownerId, Email ownerEmail, TenantName tenantName, HomePage homePage, CountryId countryId, Country country, DateTime signedUp)
 {
     Apply(new TenantSignedUp(id, ownerId, ownerEmail, tenantName, homePage, countryId, country, signedUp));
     // studio Apply(new TenantCreated(id, ownerId, ownerEmail, tenantId, tenantName, homePage, countryId, country, signedUp));
 }
Пример #25
0
 // ReSharper disable once UnusedMember.Global
 public static string CountryIdToString(CountryId x) => x.ToString();
Пример #26
0
 public async Task <Country> GetCountryAsync(CountryId id)
 {
     return(await _context.Countries.FindAsync(id));
 }
Пример #27
0
 /// <summary>
 /// Get country with specified id.
 /// </summary>
 /// <param name='countryId'>Id of country.</param>
 /// <returns>Requested country.</returns>
 /// <exception cref="ArgumentException">Thrown if no data has the requested id.</exception>
 public ICountry Get(CountryId countryId)
 {
     return(Get((Int32)countryId));
 }
Пример #28
0
        /// <summary>
        /// Returns true if AddressesModel2 instances are equal
        /// </summary>
        /// <param name="other">Instance of AddressesModel2 to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AddressesModel2 other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AddressId == other.AddressId ||
                     AddressId != null &&
                     AddressId.Equals(other.AddressId)
                     ) &&
                 (
                     Nickname == other.Nickname ||
                     Nickname != null &&
                     Nickname.Equals(other.Nickname)
                 ) &&
                 (
                     CountryId == other.CountryId ||
                     CountryId != null &&
                     CountryId.Equals(other.CountryId)
                 ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     AdministrativeArea == other.AdministrativeArea ||
                     AdministrativeArea != null &&
                     AdministrativeArea.Equals(other.AdministrativeArea)
                 ) &&
                 (
                     DependentLocality == other.DependentLocality ||
                     DependentLocality != null &&
                     DependentLocality.Equals(other.DependentLocality)
                 ) &&
                 (
                     SortingCode == other.SortingCode ||
                     SortingCode != null &&
                     SortingCode.Equals(other.SortingCode)
                 ) &&
                 (
                     Organization == other.Organization ||
                     Organization != null &&
                     Organization.Equals(other.Organization)
                 ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ) &&
                 (
                     IsPrimary == other.IsPrimary ||
                     IsPrimary != null &&
                     IsPrimary.Equals(other.IsPrimary)
                 ) &&
                 (
                     SessionToken == other.SessionToken ||
                     SessionToken != null &&
                     SessionToken.Equals(other.SessionToken)
                 ));
        }