Exemplo n.º 1
0
        protected EntertainApiResponse ValidateRestReponse(IRestResponse restResponse)
        {
            var response = new EntertainApiResponse();

            if (!_restClientWrapper.IsGoodResponse(restResponse))
            {
                response.errorSeverity = restResponse.ErrorException != null?restResponse.ErrorException.ToString() : restResponse.StatusDescription;

                response.errorMessage = string.IsNullOrEmpty(restResponse.ErrorMessage) ? restResponse.StatusDescription : restResponse.ErrorMessage;
            }

            CheckXDocumentForErrors(restResponse, response);

            return(response);
        }
Exemplo n.º 2
0
        protected decimal GetBookingCommission(EntertainApiResponse response)
        {
            decimal bookingTotal     = 0;
            decimal globalCommission = new Decimal(0.10); // decimal.Parse(0.10); // decimal.Parse(ConfigurationSettings.GetConfigurationSetting("Commision"));

            foreach (var reservation in response.reservations)
            {
                if (reservation.total > 0)
                {
                    var commision = reservation.commission.HasValue
                        ? Math.Round(reservation.total * reservation.commission.Value, 0)
                        : Math.Round(reservation.total * globalCommission, 0);

                    bookingTotal += commision;
                }
            }

            return(bookingTotal);
        }
Exemplo n.º 3
0
        protected void CheckXDocumentForErrors(IRestResponse restResponse, EntertainApiResponse response)
        {
            var document = GetXDocumentFromRestResponse(restResponse);
            var error    = document.Element("error");

            if (error != null)
            {
                var state = error.Attribute("state");

                if (state != null)
                {
                    response.errorSeverity += " - " + state.Value;
                }

                var message = error.Element("message");

                if (message != null)
                {
                    response.errorMessage += " - " + message.Value;
                }
            }
        }