Exemple #1
0
        /// <summary>
        /// Modifies rates for a particular occupant rate plan
        /// </summary>
        /// <param name="baseRatePlanOccupantRate">occupant Rate plan rate</param>
        /// <param name="registerEvent">if true, registers the event</param>
        /// <returns>Modified occupant rate plan rate</returns>
        private RatePlanRate ModifyRatePlanRates(BaseRatePlanOccupantRate baseRatePlanOccupantRate, bool registerEvent = true)
        {
            if (baseRatePlanOccupantRate == null)
            {
                return null;
            }

            if (baseRatePlanOccupantRate.Id == default(int) || baseRatePlanOccupantRate.RatePlanId == default(int))
            {
                // can't modify with bad id
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30098, "RoomTypeManager.ModifyRatePlanRate", arguments: new object[] { baseRatePlanOccupantRate }));
            }

            if (baseRatePlanOccupantRate.IsValid())
            {
                using (var tx = new BusinessTransaction())
                {
                    ratePlanRateDao.ModifyBaseOccupantRatesByRatePlanId(baseRatePlanOccupantRate);

                    tx.Commit();
                }

                if (registerEvent)
                {
                    eventTrackingManager.CreateBusinessEventAsync(baseRatePlanOccupantRate.BusinessId, BusinessEventTypesEnum.OccupancyRatePlanRateModified, baseRatePlanOccupantRate.Id.ToString(CultureInfo.InvariantCulture));
                }
            }

            return baseRatePlanOccupantRate;
        }