Пример #1
0
        BO.LineTrip SetArrivalTimeToStation(BO.Station station, BO.LineTrip lineTrip)
        {
            TimeSpan arrivalTime = TimeSpan.Zero;

            // Summarize the time of the line until it reaches the given station
            foreach (var lineStation in GetAllLineStationsByLineID(lineTrip.LineId))
            {
                arrivalTime += lineStation.TimeFromNext;
                if (lineStation.Station == station.Code)
                {
                    break;
                }
            }

            lineTrip.ArrivalTimeToStation = lineTrip.CurrentTimeToStation = arrivalTime + lineTrip.StartAt;
            return(lineTrip);
        }
Пример #2
0
 /// <summary>
 /// Get a single line trip from the database
 /// build the line trip with the line code and the last station of the line
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public BO.LineTrip GetLineTrip(int id)
 {
     BO.LineTrip lineTripBo = new BO.LineTrip();
     try
     {
         var lineTripDo = dl.GetLineTrip(id);
         lineTripDo.CopyPropertiesTo(lineTripBo);
         var line = GetLine(lineTripBo.LineId);
         lineTripBo.LineCode    = line.Code;
         lineTripBo.LastStation = line.LastStationName;
         return(lineTripBo);
     }
     catch (DO.BadLineTripException ex)
     {
         throw new BO.BadLineTripException(id, ex.Message);
     }
 }
Пример #3
0
 public TimeSpan CalculateDistance(BO.LineTrip trip)
 {
     return(dl.CalculateDistance(LineTripBoDoAdapter(trip)));
 }
Пример #4
0
 public void DeleteLineTrip(BO.LineTrip trip)
 {
     dl.DeleteLineTrip(LineTripBoDoAdapter(trip));
 }
Пример #5
0
 public void AddLineTrip(BO.LineTrip trip)
 {
     dl.AddLineTrip(LineTripBoDoAdapter(trip));
 }
Пример #6
0
 public BO.LineTrip LineTripDoBoAdapter(DO.LineTrip lineTripDo)
 {
     BO.LineTrip lineTripBo = new BO.LineTrip();
     lineTripDo.CopyPropertiesTo(lineTripBo);
     return(lineTripBo);
 }
Пример #7
0
 DO.LineTrip LineTripBoDoAdapter(BO.LineTrip lineTripBo)
 {
     DO.LineTrip lineTripDo = new DO.LineTrip();
     lineTripBo.CopyPropertiesTo(lineTripDo);
     return(lineTripDo);
 }
Пример #8
0
        /// <summary>
        /// Add new line trip to the database
        /// </summary>
        /// <param name="lineTrip"></param>
        /// <returns></returns>
        public int AddLineTrip(BO.LineTrip lineTrip)
        {
            var lineTripDo = lineTrip.CopyPropertiesToNew(typeof(DO.LineTrip)) as DO.LineTrip;

            return(dl.AddLineTrip(lineTripDo));
        }