public ScheduleLoader(ScheduleHeaderLoader scheduleRecordsLoader, ScheduleLocationLoader locationLoader, ScheduleChangeLoader changeLoader, ILogger logger)
 {
     _logger    = logger;
     _schedules = scheduleRecordsLoader;
     _locations = locationLoader;
     _changes   = changeLoader;
 }
        internal long Add(long scheduleId, long scheduleLocationId, ScheduleChange change)
        {
            var databaseId = GetNewId();

            var row = Table.NewRow();

            row["Id"]                       = databaseId;
            row["ScheduleId"]               = scheduleId;
            row["ScheduleLocationId"]       = scheduleLocationId;
            row["Category"]                 = SetNullIfEmpty(change.Category);
            row["TrainIdentity"]            = SetNullIfEmpty(change.TrainIdentity);
            row["NrsHeadCode"]              = SetNullIfEmpty(change.HeadCode);
            row["ServiceCode"]              = SetNullIfEmpty(change.ServiceCode);
            row["PortionId"]                = SetNullIfEmpty(change.PortionId);
            row["PowerType"]                = SetNullIfEmpty(change.PowerType);
            row["TimingLoadType"]           = SetNullIfEmpty(change.TimingLoadType);
            row["Speed"]                    = SetNullIfEmpty(change.Speed);
            row["OperatingCharacteristics"] = SetNullIfEmpty(change.OperatingCharacteristics);
            row["SeatClass"]                = ScheduleHeaderLoader.ConvertAccommodationClass(change.SeatClass);
            row["SleeperClass"]             = ScheduleHeaderLoader.ConvertAccommodationClass(change.SleeperClass);
            row["ReservationIndicator"]     = ScheduleHeaderLoader.ConvertReservationIndicator(change.ReservationIndicator);
            row["Catering"]                 = SetNullIfEmpty(change.Catering);
            row["Branding"]                 = SetNullIfEmpty(change.Branding);
            row["EuropeanUic"]              = SetNullIfEmpty(change.Uic);
            row["RetailServiceId"]          = SetNullIfEmpty(change.RetailServiceId);

            Table.Rows.Add(row);
            return(databaseId);
        }
Exemple #3
0
        internal long Add(Association association)
        {
            var databaseId = GetNewId();
            var row        = Table.NewRow();

            row["Id"]                 = databaseId;
            row["Action"]             = ScheduleHeaderLoader.MapAction(association.Action, _logger);
            row["StpIndicator"]       = association.StpIndicator.ToString();
            row["MainUid"]            = association.MainUid;
            row["AssociatedUid"]      = association.AssociatedUid;
            row["RunsFrom"]           = association.RunsFrom;
            row["RunsTo"]             = (object)association.RunsTo ?? DBNull.Value;
            row["DayMask"]            = DayMaskConverter.Convert(association.DayMask);
            row["Category"]           = SetNullIfEmpty(association.Category);
            row["DateIndicator"]      = SetNullIfEmpty(association.DateIndicator);
            row["LocationId"]         = _lookup.Find(association.Location);
            row["MainSequence"]       = association.MainSequence;
            row["AssociatedSequence"] = association.AssociationSequence;
            row["AssociationType"]    = SetNullIfEmpty(association.AssociationType);
            Table.Rows.Add(row);
            return(databaseId);
        }