Пример #1
0
        public Output ProcessOutput(Input input)
        {
            if (!CheckOutputForNullValues(input))
            {
                return(null);
            }
            var passengerData = ProcessPassengersData(input.Passenger, input.Route);

            if (passengerData == null)
            {
                return(null);
            }

            var output = new Output();

            output.Passengers        = input.Passenger.Count;
            output.GeneralPassengers = GetPassengersSum(input.Passenger, MembershipType.general);
            output.LoyaltyPassengers = GetPassengersSum(input.Passenger, MembershipType.loyalty);
            output.AirlinePassengers = GetPassengersSum(input.Passenger, MembershipType.airline);
            output.Bags = GetTotalBags(passengerData);
            output.LoyaltyPointsUsed     = GetTotalUsedLoyaltyPoints(passengerData);
            output.CostOfFlight          = GetTotalFlightCost(input.Passenger.Count, input.Route.CostToAirline);
            output.RevenueBeforeDiscount = GetRevenueBeforeDiscount(input.Passenger.Count, input.Route.TicketPrice);
            output.RevenueAfterDiscount  = GetRevenueAfterDiscount(output.RevenueBeforeDiscount,
                                                                   output.AirlinePassengers,
                                                                   output.LoyaltyPointsUsed,
                                                                   input.Route.TicketPrice);
            output.CanFlightProceed = output.RevenueAfterDiscount > output.CostOfFlight;

            OutputGenerator.GenerateJsonOutput(output);
            //The return output can be processed further for responses to the client
            //It is not implemented due to remain in the scope of the project
            return(output);
        }