コード例 #1
0
ファイル: PolicyService.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Return cancellation policy based on property shortname or content ID, culture, booking source and channel shortname.
        /// </summary>
        /// <param name="cancellationPolicyRequest">CancellationPolicyRequest</param>
        /// <returns>Cancellation policy</returns>
        public PropertyCancellationPolicyDto GetCancellationPolicy(CancellationPolicyRequestDto cancellationPolicyRequest)
        {
            // the service accepts property short name and channel short name in the request,
            // but internally everything works with ids, so we need to find them
            long? propertyId = null;
            int? channelId = null;

            #region Preconditions
            // request and property short name are required
            if (cancellationPolicyRequest == null
                || string.IsNullOrEmpty(cancellationPolicyRequest.PropertyShortName))
            {
                throw new ArgumentNullException();
            }

            // property short name has to be valid
            propertyId = businessManager.GetBusinessIdByShortName(cancellationPolicyRequest.PropertyShortName);
            if (propertyId.HasValue == false)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30121, GetMethodName(),
                                                                             additionalDescriptionParameters: new object[] { cancellationPolicyRequest.PropertyShortName }));
            }

            // channel short name has to be valid (if present in the request)
            if (string.IsNullOrEmpty(cancellationPolicyRequest.ChannelShortName) == false)
            {
                channelId = distributionManager.GetChannelIdByShortName(cancellationPolicyRequest.ChannelShortName);
                if (channelId.HasValue == false)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30122, GetMethodName(),
                                                                                 additionalDescriptionParameters: new object[] { cancellationPolicyRequest.ChannelShortName }));
                }
            }
            #endregion
            
            var cancellationRequest = new CancellationPolicyRequest
            {
                Culture = cancellationPolicyRequest.Culture,
                IsOnlineOverride = cancellationPolicyRequest.IsOnlineOverride,
                PropertyId = propertyId.Value,
                ChannelId = channelId.GetValueOrDefault()
            };

            var cancellationPolicy = cancellationPolicyManager.GetCancellationPolicy(cancellationRequest);

            return Mapper.Map<PropertyCancellationPolicy, PropertyCancellationPolicyDto>(cancellationPolicy);
        }
コード例 #2
0
ファイル: PolicyService.cs プロジェクト: ognjenm/egle
 /// <summary>
 /// Return cancellation policy based on property shortname or content ID, culture, booking source and channel shortname.
 /// </summary>
 /// <param name="cancellationPolicyRequest">CancellationPolicyRequest</param>
 /// <returns>Cancellation policy</returns>
 public CancellationPolicy GetCancellationPolicy(CancellationPolicyRequest cancellationPolicyRequest)
 {
     return cancellationPolicyManager.GetCancellationPolicy(cancellationPolicyRequest);
 }