예제 #1
0
        /// <summary>
        /// Дополняет текущий отель по данным из отеля извне
        /// </summary>
        /// <returns>Успешность объединения</returns>
        public bool TryMerge(Hotel other)
        {
            if (other == null || other.Id != Id || other.Supplier != Supplier)
            {
                return(false);
            }

            if (!other.Name.IsNullOrEmpty())
            {
                Name ??= new Dictionary <Language, string>();
                Name.AddRangeWithNonrecurringKey(other.Name);
            }

            if (!other.Info.IsNullOrEmpty())
            {
                Info ??= new Dictionary <Language, string>();
                Info.AddRangeWithNonrecurringKey(other.Info);
            }

            if (!other.Address.IsNullOrEmpty())
            {
                Address ??= new Dictionary <Language, List <string> >();
                Address.AddRangeWithNonrecurringKey(other.Address);
            }

            if (!other.Features.IsNullOrEmpty())
            {
                Features ??= new Dictionary <Language, List <Feature> >();
                Features.AddRangeWithNonrecurringKey(other.Features);
            }

            if (!other.Description.IsNullOrEmpty())
            {
                Description ??= new Dictionary <Language, string>();
                Description.AddRangeWithNonrecurringKey(other.Description);
            }

            if (!other.Distances.IsNullOrEmpty())
            {
                Distances ??= new Dictionary <Language, List <Distance> >();
                Distances.AddRangeWithNonrecurringKey(other.Distances);
            }

            CheckInTime    = string.IsNullOrEmpty(CheckInTime) ? other.CheckInTime : CheckInTime;
            CheckOutTime   = string.IsNullOrEmpty(CheckOutTime) ? other.CheckOutTime : CheckOutTime;
            CityId         = string.IsNullOrEmpty(CityId) ? other.CityId : CityId;
            ResortId       = string.IsNullOrEmpty(ResortId) ? other.ResortId : ResortId;
            HotelChainName = string.IsNullOrEmpty(HotelChainName) ? other.HotelChainName : HotelChainName;

            Photos = Photos.IsNullOrEmpty() ? other.Photos : Photos;
            Phones = Phones.IsNullOrEmpty() ? other.Phones : Phones;

            StarRating ??= other.StarRating;
            PosLatitude ??= other.PosLatitude;
            PosLongitude ??= other.PosLongitude;
            CustomerRating ??= other.CustomerRating;

            return(true);
        }