Beispiel #1
0
        /// <summary>
        /// Get Summary Report of Travel
        /// </summary>
        /// <param name="airtravelDetail"></param>
        /// <returns></returns>
        public string GetSummaryReport(AirTravelDetail airtravelDetail)
        {
            try
            {
                var summaryReport = new SummaryReport(airtravelDetail)
                {
                    TotalPassengerCount = airtravelDetail.PassengerDetails.Count,
                    GeneralPassengerCount = airtravelDetail.PassengerDetails.Count(x => x.Type == PassengerType.general),
                    AirlinePassengerCount = airtravelDetail.PassengerDetails.Count(x => x.Type == PassengerType.airline),
                    LoyaltyPassengerCount = airtravelDetail.PassengerDetails.Count(x => x.Type == PassengerType.loyalty),
                    TotalLoyaltyPointsRedeemed = airtravelDetail.PassengerDetails.Where(x => x.IsRedeemed).Sum(x => x.LoyaltyPoints),
                };

                return summaryReport.ToString();
            }
            catch (Exception)
            {

                throw;
            }
        }
 public SummaryReport(AirTravelDetail airtravelDetail)
 {
     _airTravelDetail = airtravelDetail;
 }
Beispiel #3
0
        /// <summary>
        /// Get Travel Detail
        /// </summary>
        /// <returns></returns>
        private AirTravelDetail GetAirTravelDetail()
        {
            try
            {
                AirTravelDetail airTravelDetail = new AirTravelDetail();
                List<string[]> passengers = new List<string[]>();

                string[] flightInfo = ExtractDetail(AirlineConstants.Aircraft).FirstOrDefault();
                string[] routeDetail = ExtractDetail(AirlineConstants.Route).FirstOrDefault();
                passengers.AddRange(ExtractDetail(AirlineConstants.General));
                passengers.AddRange(ExtractDetail(AirlineConstants.Loyalty));
                passengers.AddRange(ExtractDetail(AirlineConstants.Airline));

                airTravelDetail.FlightDetail = new FlightDetail()
                {
                    FlightName = flightInfo[1],
                    NoOfSeats = Convert.ToInt32(flightInfo[2]),
                    Route = new Route()
                    {
                        Origin = routeDetail[1],
                        Destination = routeDetail[2],
                        CostPerPassenger = Convert.ToInt32(routeDetail[3]),
                        TicketPrice = Convert.ToInt32(routeDetail[4]),
                        MinimumTakeOfLoadPercentage = Convert.ToInt32(routeDetail[5])
                    }
                };

                passengers.ForEach(x =>
                {
                    airTravelDetail.PassengerDetails.Add(new PassengerDetail()
                    {
                        Type = (PassengerType)Enum.Parse(typeof(PassengerType), x[0]),
                        Name = x[1],
                        Age = Convert.ToInt32(x[2]),
                        LoyaltyPoints = x.Length > 3 ? Convert.ToInt32(x[3]) : 0,
                        IsRedeemed = x.Length > 4 ? Convert.ToBoolean(x[4]) : false,
                        ExtraBaggage = x.Length > 5 ? Convert.ToBoolean(x[5]) : false,
                    });
                });

                return airTravelDetail;
            }
            catch (Exception)
            {

                throw;
            }
        }