コード例 #1
0
        public Tgvs GetJourney(Lines line, DateTime dateOfDeparture)
        {
            IEnumerable <Tgvs> tgvs = GetWithLine(line.Id);
            Tgvs bestTgv            = BestTgv(tgvs, dateOfDeparture.TimeOfDay);

            if (bestTgv == null)
            {
                return(EarliestTgv(tgvs));
            }

            IEnumerable <HolidayPeriods> holidayPeriods = holidayPeriodService.All();

            foreach (HolidayPeriods h in holidayPeriods)
            {
                if (h.StartDate.CompareTo(dateOfDeparture) <= 0 && h.EndDate.CompareTo(dateOfDeparture) >= 0)
                {
                    bestTgv.AvailableBusinessSeats = (int)(bestTgv.AvailableBusinessSeats * (1 + h.ExtraSeatsPercent));
                    bestTgv.AvailableEconomicSeats = (int)(bestTgv.AvailableEconomicSeats * (1 + h.ExtraSeatsPercent));
                    bestTgv.BasePriceBusiness     *= 1 + h.ExtraPricePercent;
                    bestTgv.BasePriceEconomic     *= 1 + h.ExtraPricePercent;
                }
            }

            IEnumerable <Tickets> tickets = ticketDAO.AllForTGV(bestTgv.Id, dateOfDeparture);

            foreach (Tickets t in tickets)
            {
                if (t.IsCancelled == 0)
                {
                    if (t.IsBusiness == 0)
                    {
                        bestTgv.AvailableBusinessSeats--;
                    }
                    else
                    {
                        bestTgv.AvailableEconomicSeats--;
                    }
                }
            }

            return(bestTgv);
        }
コード例 #2
0
 public IEnumerable<Tickets> AllForTGV(int tgvId, DateTime dateOfDeparture)
 {
     if (dateOfDeparture == null)
         throw new ArgumentException("There was no date given.");
     return ticketDAO.AllForTGV(tgvId, dateOfDeparture);
 }