flight fare calculation

mail@pastecode.io avatar
unknown
csharp
2 years ago
2.2 kB
3
Indexable
Never
 private FlightPrebookAddBookOrderViewModel PrepareFlightFares(FlightPrebookAddBookOrderViewModel request)
        {
            var adtCount = request.Travelers.Select(x => x.PassengerTypeCode == "ADT").Count();
            var chdCount = request.Travelers.Select(x => x.PassengerTypeCode == "CHD").Count();
            var infCount = request.Travelers.Select(x => x.PassengerTypeCode == "INF").Count();

            foreach (var flight in request.Plan.Flights)
            { 
                // ADT
                // flight.Fares.AdtFare.BaseFare = flight.Fares.AdtFare.BaseFare * adtCount;
                // flight.Fares.AdtFare.Tax = flight.Fares.AdtFare.Tax * adtCount;
                // flight.Fares.AdtFare.TaxVQ = flight.Fares.AdtFare.TaxVQ * adtCount;
                flight.Fares.AdtFare.TotalFare = flight.Fares.AdtFare.TotalFare * adtCount;
                flight.Fares.AdtFare.MilePrice = flight.Fares.AdtFare.MilePrice * adtCount;

                // CHD
                // flight.Fares.ChdFare.BaseFare = flight.Fares.ChdFare.BaseFare * chdCount;
                // flight.Fares.ChdFare.Tax = flight.Fares.ChdFare.Tax * chdCount;
                // flight.Fares.ChdFare.TaxVQ = flight.Fares.ChdFare.TaxVQ * chdCount;
                flight.Fares.ChdFare.TotalFare = flight.Fares.ChdFare.TotalFare * chdCount;
                flight.Fares.ChdFare.MilePrice = flight.Fares.ChdFare.MilePrice * chdCount;

                //INF
                // flight.Fares.InfFare.BaseFare = flight.Fares.InfFare.BaseFare * infCount;
                // flight.Fares.InfFare.Tax = flight.Fares.InfFare.Tax * infCount;
                // flight.Fares.InfFare.TaxVQ = flight.Fares.InfFare.TaxVQ * infCount;
                flight.Fares.InfFare.TotalFare = flight.Fares.InfFare.TotalFare * infCount;
                flight.Fares.InfFare.MilePrice = flight.Fares.InfFare.MilePrice * infCount;

                flight.Fares.Total = flight.Fares.AdtFare.TotalFare + flight.Fares.ChdFare.TotalFare + flight.Fares.InfFare.TotalFare;
                flight.Fares.MilePrice = flight.Fares.AdtFare.MilePrice + flight.Fares.ChdFare.MilePrice + flight.Fares.InfFare.MilePrice;

            }

            return request;

        }