Beispiel #1
0
        /// <summary>
        /// Get Rate Cache for a Room Type and Rate Plan
        /// </summary>
        /// <param name="businessShortName">business for this request as short name</param>
        /// <param name="roomTypeId">Room Type Id</param>
        /// <param name="ratePlanId">Rate Plan Id</param>
        /// <param name="ratePlanType">Rate Plan Type</param>
        /// <returns>List containing Rate Cache for Room Type and Rate Plan</returns>
        public List<RateCache> GetAllByRoomTypeAndRatePlanId(string businessShortName, int roomTypeId, int ratePlanId, RatePlanTypeEnum ratePlanType = RatePlanTypeEnum.Unknown)
        {
            var rateCacheItems = rateCacheDao.GetAllByRoomTypeAndRatePlanId(roomTypeId, ratePlanId, ratePlanType);

            if (Cache.Cache.BusinessByShortName.ContainsKey(businessShortName))
            {
                long businessId = Cache.Cache.BusinessByShortName.TryGetValue(businessShortName).Id;

                if (PromotionCalculator.UseEngine && businessId != default(long))
                {
                    promotionCalculator.CalculatePriceForDates(businessId, rateCacheItems);
                }
            }

            return rateCacheItems;
        }
Beispiel #2
0
        /// <summary>
        /// Get Rate Cache for a Room Type and Rate Plan
        /// </summary>
        /// <param name="businessId">business for this request</param>
        /// <param name="roomTypeId">Room Type Id</param>
        /// <param name="ratePlanId">Rate Plan Id</param>
        /// <param name="ratePlanType">Rate Plan Type</param>
        /// <returns>List containing Rate Cache for Room Type and Rate Plan</returns>
        public List<RateCache> GetAllByRoomTypeAndRatePlanId(long businessId, int roomTypeId, int ratePlanId, RatePlanTypeEnum ratePlanType = RatePlanTypeEnum.Unknown)
        {
            var rateCacheItems = rateCacheDao.GetAllByRoomTypeAndRatePlanId(roomTypeId, ratePlanId, ratePlanType);

            if (PromotionCalculator.UseEngine && businessId != default(long))
            {
                promotionCalculator.CalculatePriceForDates(businessId, rateCacheItems);
            }
            return rateCacheItems;
        }
Beispiel #3
0
 /// <summary>
 /// Get all active room types for a business by room type id(for Content)
 /// </summary>
 /// <param name="businessId">Business Id</param>
 /// <param name="roomTypeId">Room Type Id</param>
 /// <param name="ratePlanType">Rate Plan type</param>
 /// <returns>List of Room Types for a business</returns>
 public List<RoomType> GetAllActiveWithRatePlansForBusinessByRoomTypeId(long businessId, int roomTypeId, RatePlanTypeEnum ratePlanType = RatePlanTypeEnum.Unknown)
 {
     return roomTypeDao.GetAllActiveWithRatePlansForBusinessByRoomTypeId(businessId, roomTypeId, ratePlanType);
 }
Beispiel #4
0
        /// <summary>
        /// Get all RateCache for a room type and rate plan
        /// </summary>
        /// <param name="roomTypeId">Room Type</param>
        /// <param name="ratePlanId">Rate Plan</param>
        /// <param name="ratePlanType">Rate Plan Type</param>
        public List<RateCache> GetAllByRoomTypeAndRatePlanId(int roomTypeId, int ratePlanId, RatePlanTypeEnum ratePlanType = RatePlanTypeEnum.Unknown)
        {
            string sqlStatement = RATE_CACHE_SQL_STATEMENT + @"
                INNER JOIN Pricing.RatePlan RP ON RP.Id = RC.RatePlanId
                WHERE RC.RoomTypeId = @RoomTypeId AND RC.RatePlanId = @RatePlanId";

            if (ratePlanType != RatePlanTypeEnum.Unknown)
            {
                sqlStatement = sqlStatement + " AND RP.RatePlanTypeCode = @RatePlanTypeCode";
            }

            var parameters = new List<SqlParameter>
                             {
                DbHelper.CreateParameter(RateCacheMapper.Parameters.RoomTypeId, roomTypeId),
                DbHelper.CreateParameter(RateCacheMapper.Parameters.RatePlanId, ratePlanId),
                DbHelper.CreateParameter(RatePlanMapper.Parameters.RatePlanTypeCode, ratePlanType.GetCode())
                             };

            return DbHelper.CreateInstanceList(sqlStatement, RateCacheMapper.MapRecord, parameters: parameters);
        }
Beispiel #5
0
        /// <summary>
        /// Get all active room types for a business and room type (for Content)
        /// </summary>
        /// <param name="businessId">Business Id</param>
        /// <param name="roomTypeId">Room Type Id</param>
        /// <param name="ratePlanType">Rate Plan type</param>
        /// <returns>List of Room Types for a business</returns>
        public List<RoomType> GetAllActiveWithRatePlansForBusinessByRoomTypeId(long businessId, int roomTypeId, RatePlanTypeEnum ratePlanType = RatePlanTypeEnum.Unknown)
        {
            const string SQL_WHERE = @" WHERE BusinessId = @BusinessId AND IsActive = 1 AND RoomTypeId = @RoomTypeId";
            const string SQL_RATE_FILTER = @" AND RatePlanTypeCode = @RatePlanTypeCode";

            var sqlQuery = string.Concat(PRODUCT_TYPE_VIEW_QUERY, SQL_WHERE);

            //only if a rate plane type is supplied filter by the type
            if (ratePlanType != RatePlanTypeEnum.Unknown)
            {
                sqlQuery = string.Concat(sqlQuery, SQL_RATE_FILTER);
            }

            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(RoomTypeMapper.Parameters.BusinessId, businessId),
                DbHelper.CreateParameter(RoomTypeMapper.Parameters.RoomTypeId, roomTypeId),
                DbHelper.CreateParameter(RatePlanMapper.Parameters.RatePlanTypeCode, ratePlanType.GetCode())
            };

            return DbHelper.CreateInstanceList(sqlQuery, RoomTypeMapper.MapRecordWithRatePlanInformation, parameters: parameters);
        }