コード例 #1
0
        public static TrainChangeOfOrigin MapFromBody(dynamic body)
        {
            TrainChangeOfOrigin change = new TrainChangeOfOrigin();
            change.Stanox = (string)body.loc_stanox;
            change.NewDepartureTime = UnixTsToDateTime((string)body.dep_timestamp).Value;
            change.ChangedTime = UnixTsToDateTime((string)body.coo_timestamp);
            change.ReasonCode = (string)body.reason_code;

            return change;
        }
コード例 #2
0
        private bool AddChangeOfOrigin(TrainChangeOfOrigin tOrigin)
        {
            Activation activation = null;
            if (TrainExists(tOrigin.TrainId, out activation))
            {
                TiplocCode tiploc = _tiplocRepository.GetTiplocByStanox(tOrigin.Stanox);
                if (tiploc != null)
                {
                    Trace.TraceInformation("Saving Change of Origin to: {0} @ {1}", tOrigin.TrainId, tOrigin.Stanox);

                    const string insertStop = @"
                        INSERT INTO [LiveTrainChangeOfOrigin]
                           ([TrainId]
                           ,[ReasonCode]
                           ,[NewTiplocId]
                           ,[NewDepartureTime]
                           ,[ChangedTime])
                        VALUES
                           (@trainId
                           ,@reasonCode
                           ,@newTiplocId
                           ,@newDepartureTime
                           ,@changedTime)";

                    ExecuteNonQuery(insertStop, new
                    {
                        trainId = activation.DbId,
                        reasonCode = tOrigin.ReasonCode,
                        newTiplocId = tiploc.TiplocId,
                        newDepartureTime = tOrigin.NewDepartureTime,
                        changedTime = tOrigin.ChangedTime
                    });
                }
            }
            return false;
        }