Exemplo n.º 1
0
 public RTSecondTripBunkFilter(PolicyType policyType, Bunk departureBunk)
 {
     m_policyType    = policyType;
     m_departureBunk = departureBunk;
 }
Exemplo n.º 2
0
        private static IEnumerable <Bunk> getBunks(Flight flight, Command.Domain.FlightQuery.Bunk originalBunk, BunkFilter bunkFilter, out List <Bunk> filteredBunks)
        {
            var result = new List <Bunk>();

            filteredBunks = new List <Bunk>();
            var bunkDatas = FoundationService.QueryBunk(flight.Airline, flight.Departure.Code, flight.Arrival.Code, flight.FlightDate, originalBunk.Code);

            foreach (var bunkData in bunkDatas)
            {
                Bunk item = null;
                if (bunkData is Foundation.Domain.EconomicBunk)
                {
                    var discount = (bunkData as Foundation.Domain.EconomicBunk).GetDiscount(originalBunk.Code);
                    if (discount < 0)
                    {
                        continue;
                    }
                    item = new EconomicBunk(originalBunk.Code)
                    {
                        Discount = discount
                    };
                }
                else if (bunkData is Foundation.Domain.FirstBusinessBunk)
                {
                    var firstBusinessBunk = bunkData as Foundation.Domain.FirstBusinessBunk;
                    var discount          = firstBusinessBunk.GetDiscount(originalBunk.Code);
                    if (discount < 0)
                    {
                        continue;
                    }
                    item = new FirstOrBusinessBunk(originalBunk.Code)
                    {
                        Discount    = discount,
                        Description = firstBusinessBunk.Description
                    };
                }
                else if (bunkData is Foundation.Domain.PromotionBunk)
                {
                    item = new PromotionBunk(originalBunk.Code)
                    {
                        Description = (bunkData as Foundation.Domain.PromotionBunk).Description
                    };
                }
                else if (bunkData is Foundation.Domain.ProductionBunk)
                {
                    item = new ProductionBunk(originalBunk.Code);
                }
                else if (bunkData is Foundation.Domain.TransferBunk)
                {
                    item = new TransferBunk(originalBunk.Code);
                }
                else if (bunkData is Foundation.Domain.FreeBunk)
                {
                    item = new FreeBunk(originalBunk.Code)
                    {
                        Description = (bunkData as Foundation.Domain.FreeBunk).Description
                    };
                }
                else if (bunkData is Foundation.Domain.TeamBunk)
                {
                    item = new TeamBunk(originalBunk.Code);
                }
                else
                {
                    continue;
                }
                if (originalBunk.Status == "A")
                {
                    item.SeatCount = 10;
                }
                else
                {
                    int count;
                    if (int.TryParse(originalBunk.Status, out count))
                    {
                        item.SeatCount = count;
                    }
                    else
                    {
                        continue;
                    }
                }
                item.EI = bunkData.EI;
                item.EndorseRegulation = bunkData.EndorseRegulation;
                item.RefundRegulation  = bunkData.RefundRegulation;
                item.ChangeRegulation  = bunkData.ChangeRegulation;
                item.Remark            = bunkData.Remarks;
                item.SuportChild       = (bunkData.PassengerType & PassengerTypeValue.Child) == PassengerTypeValue.Child;
                item.Owner             = flight;

                if (bunkFilter.Execute(bunkData))
                {
                    result.Add(item);
                }
                else
                {
                    filteredBunks.Add(item);
                }
            }
            return(result);
        }