/// <summary>
        ///   returns ture if the chain code is the same and the supplierHotel is within 200 metres or less of the actual hotel location.
        /// 
        /// Assumption: 1 degree of latitude or longitude is equal to 111km
        /// Assumption: case Sensitive when comparing chain code 
        /// </summary>
        public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel)
        {
            bool isChainCodeEqual = string.Compare(supplierHotel.ChainCode, hotel.ChainCode, false) == 0 ? true : false;

            double distanceApartInMeter = LocationHelpers.DistanceBetweenPlaces(supplierHotel.Longitude, supplierHotel.Latitude,
                hotel.Longitude, hotel.Latitude);
            bool locationSatisfy = distanceApartInMeter <= 200 ? true : false;

            return (isChainCodeEqual && locationSatisfy);
        }
        public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel)
        {
            //reverse
            var reversedSName = NameHelpers.ReverseWordInASentence(supplierHotel.Name);

            //remove punctuation
            var pureSName = NameHelpers.RemovePunctuationAndSpaceInAString(reversedSName);
            var pureName = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Name);

            var match = string.Compare(pureSName, pureName, true) == 0 ? true : false;
            return match;
        }
        /// <summary>
        /// Returns true if Both hotel's name and Address match when punctuation is excluded
        /// 
        /// Assumption: Space will be removed when comparing
        /// Assumption: case insensitive when comparing
        /// </summary>
        /// <param name="supplierHotel"></param>
        /// <param name="hotel"></param>
        /// <returns></returns>
        public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel)
        {
            var pureSName = NameHelpers.RemovePunctuationAndSpaceInAString(supplierHotel.Name);
            var pureSAddress = NameHelpers.RemovePunctuationAndSpaceInAString(supplierHotel.Address);
            var pureName = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Name);
            var pureAddress = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Address);

            int nameCompare = string.Compare(pureSName, pureName, true);
            int addressCompare = string.Compare(pureSAddress, pureAddress, true);

            return (Math.Abs(nameCompare) + Math.Abs(addressCompare)) == 0;
        }
Example #4
0
        public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel)
        {
            string newHotelName = FilterPunctuation(supplierHotel.Name);
            string newAddress = FilterPunctuation(supplierHotel.Address);

            if (newHotelName == hotel.Name && newAddress == hotel.Address)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Example #5
0
        public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel)
        {
            string[] names = supplierHotel.Name.Split(new char[] {' '});
            Array.Reverse(names);
            StringBuilder sb = new StringBuilder();
            foreach (var item in names)
            {
                sb.Append(item);
                sb.Append(" ");
            }
            string result = sb.ToString();
            result = result.TrimEnd();

            return (result == hotel.Name) ? true : false;
        }
        public void ContraryCountryGetawaysMatcher_IsMatch_Name()
        {
            var matcher = new ContraryCountryGetawaysMatcher();

            var supplierHotel = new SupplierHotel()
                {
                    Name = "Manor Country Mayhew’s Ralph Lord"
                };
            var hotel = new Hotel()
                {
                    Name = "Lord Ralph Mayhew’s Country Manor"
                };

            var isMatch = matcher.IsMatch(supplierHotel, hotel);

            Assert.AreEqual(true, isMatch);
        }
        public void SuperfluousHotelMatcher_NotMatch_Name()
        {
            var matcher = new SuperfluousHotelMatcher();

            var supplierHotel = new SupplierHotel()
            {
                Address = "22 Carrington-Square, Dubbo, NSW.",
                Name = "*Good*-Times! HOTEL (Dubbo)"
            };
            var hotel = new Hotel()
            {
                Address = "22 Carrington Square, Dubbo NSW",
                Name = "Good Times Hotel, Dubbo, AFEGGDFA"
            };

            var isMatch = matcher.IsMatch(supplierHotel, hotel);

            Assert.AreEqual(false, isMatch);
        }
        public void ThereaboutsHolidaysMatcher_NotMatch_ChainCode_Distance()
        {
            var matcher = new ThereaboutsHolidaysMatcher();

            var supplierHotel = new SupplierHotel()
            {
                ChainCode = "UH",
                Latitude = 38.001M,
                Longitude = -77.001M
            };
            var hotel = new Hotel()
            {
                ChainCode = "HH",
                Latitude = 39.002M,
                Longitude = -77.002M
            };

            var isMatch = matcher.IsMatch(supplierHotel, hotel);

            Assert.AreEqual(false, isMatch);
        }
        protected override Task ProcessHotelWorkItem(HotelWorkItem workItem, CancellationToken cancellationToken)
        {
            IKey hotelKey = new AppacitiveDAL.HotelKey()
            {
                HotelArticleId = workItem.ArticleId, HotelId = Convert.ToInt64(workItem.HotelId), SupplierFamily = workItem.SupplierFamily
            };

            ISupplierHotelDataProvider supplierHotelDataProvider = new SupplierHotelDataProvider();

            List <SupplierHotel> sourceSupplierHotels = new AppacitiveDAL.DatabaseManager().GetSupplierHotelIdsByHotelIdSupplierFamily(hotelKey);

            List <SupplierHotel> destinationSupplierHotels = supplierHotelDataProvider.GetSupplierHotels(hotelKey);

            foreach (var sourceSupplierHotel in sourceSupplierHotels)
            {
                SupplierHotel supplierHotel = destinationSupplierHotels.Find(x => x.Equals(sourceSupplierHotel));
                if (supplierHotel == null)
                {
                    // New Hotel SupplierHotel
                    supplierHotelDataProvider.InsertSupplierHotel(hotelKey, sourceSupplierHotel);
                }
                else
                {
                    // Old Hotel SupplierHotel
                    if (!supplierHotel.IsUpdated(sourceSupplierHotel))
                    {
                        supplierHotelDataProvider.UpdateSupplierHotel(hotelKey, sourceSupplierHotel);
                    }

                    destinationSupplierHotels.Remove(supplierHotel);
                }
            }

            destinationSupplierHotels.ForEach(x => supplierHotelDataProvider.DeleteSupplierHotel(hotelKey, x));

            return(null);
        }
 public void DeleteSupplierHotel(IKey hotelKey, SupplierHotel supplierHotel)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Compare the supplierHotel and hotel by using a MatcherClassName using reflection
 /// </summary>
 /// <param name="supplierHotel"></param>
 /// <param name="hotel"></param>
 /// <param name="matcherClassName"></param>
 /// <returns></returns>
 public static bool IsMatch(SupplierHotel supplierHotel, Hotel hotel, string matcherClassName)
 {
     return GetMatcherByName(matcherClassName).IsMatch(supplierHotel, hotel);
 }