internal long Add(ScheduleId id, ScheduleDetails details, ScheduleExtraData extra) { bool isCancelOrDelete = details.StpIndicator == StpIndicator.C || details.Action == RecordAction.Delete; var databaseId = GetNewId(); var row = Table.NewRow(); row["Id"] = databaseId; row["Action"] = MapAction(details.Action, _logger); row["StpIndicator"] = details.StpIndicator.ToString(); row["TimetableUid"] = details.TimetableUid; row["RunsFrom"] = details.RunsFrom; row["RunsTo"] = (object)details.RunsTo ?? DBNull.Value; row["DayMask"] = DayMaskConverter.Convert(details.DayMask); row["BankHolidayRunning"] = DayMaskConverter.ConvertBankHoliday(details.BankHolidayRunning, isCancelOrDelete); row["Status"] = SetNullIfEmpty(details.Status); row["Category"] = SetNullIfEmpty(details.Category); row["TrainIdentity"] = SetNullIfEmpty(details.TrainIdentity); row["NrsHeadCode"] = SetNullIfEmpty(details.HeadCode); row["ServiceCode"] = SetNullIfEmpty(details.ServiceCode); row["PortionId"] = SetNullIfEmpty(details.PortionId); row["PowerType"] = SetNullIfEmpty(details.PowerType); row["TimingLoadType"] = SetNullIfEmpty(details.TimingLoadType); row["Speed"] = SetNullIfEmpty(details.Speed); row["OperatingCharacteristics"] = SetNullIfEmpty(details.OperatingCharacteristics); row["SeatClass"] = ConvertAccommodationClass(details.SeatClass, isCancelOrDelete); row["SleeperClass"] = ConvertAccommodationClass(details.SleeperClass, isCancelOrDelete); row["ReservationIndicator"] = ConvertReservationIndicator(details.ReservationIndicator, isCancelOrDelete); row["Catering"] = SetNullIfEmpty(details.Catering); row["Branding"] = SetNullIfEmpty(details.Branding); // Extra data from BX record if (extra != null) { GetNewId(); //Skip an Id to keep it synced with record in file row["EuropeanUic"] = SetNullIfEmpty(extra.UIC); row["Toc"] = SetNullIfEmpty(extra.Toc); row["ApplicableTimetable"] = extra.ApplicableTimetableCode == "Y" ? 1 : 0; row["RetailServiceId"] = SetNullIfEmpty(extra.RetailServiceId); } Table.Rows.Add(row); return(databaseId); }
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); }
public void ConvertEmpty(string mask) { Assert.Equal(DBNull.Value, DayMaskConverter.Convert(mask)); }
public void ConvertMask(string mask, byte expected) { Assert.Equal(expected, DayMaskConverter.Convert(mask)); }