コード例 #1
0
        private void CalculateReservationTask()
        {
            string fromStation = connectionpath.ConnectionsParts[Part].Route.From;

            to = part;

            while (to + 1 < Count && connectionpath.ConnectionsParts[to].Connection.Id == connectionpath.ConnectionsParts[to + 1].Connection.Id)
            {
                to++;
            }

            string endStation = connectionpath.ConnectionsParts[to].Route.To;

            if (connectionpath.ConnectionsParts[to].Connection.Train.Type == "Pośpieszny")
            {
                SourcePicture = "/Resources/pospMsc.png";
            }
            else if (connectionpath.ConnectionsParts[to].Connection.Train.Type == "Ekspres")
            {
                SourcePicture = "/Resources/exMsc.png";
            }
            try
            {
                Seats = unitOfWork.GetSeats(connectionpath, part, to);
                if (Seats.Count == 0)
                {
                    endStation = connectionpath.ConnectionsParts[part].Route.To;
                    to         = part;
                    Seats      = unitOfWork.GetSeats(connectionpath, part, to);
                    if (Seats.Count == 0)
                    {
                        SendMessage("Brak miejsc.");
                        IsOK = false;
                        Cancel();
                        return;
                    }
                }
                if (Seats.Count < Ticket.NumberOfSeats)
                {
                    SendMessage(string.Format("Zostało miejsc: {0}", Seats.Count));
                    IsOK = false;
                    Cancel();
                    return;
                }
            }
            catch (AggregateException e)
            {
                SendMessage(InformationToUser.ServerError);
                IsOK = false;
                Cancel();
                return;
            }
            Seats.Sort((a, b) => a - b);
            CurrentReservation = String.Format("{0,10} => {1,10}", fromStation, endStation);
        }