Beispiel #1
0
 public void Edit(string title, decimal?tgtLast, decimal?tgtInit, decimal?tgtInt,
                  DateTime?dateLast, DateTime?dateInit, int?dateInt, DeadlineOptions opts)
 {
     Title              = title;
     TargetLastCompl    = tgtLast;
     TargetInit         = tgtInit;
     TargetInterval     = tgtInt;
     DateLastCompl      = dateLast;
     DateInit           = dateInit;
     DateIntervalInDays = dateInt;
     opts.SetId(Id);
     DeadlineOptions = opts;
     Validate();
 }
Beispiel #2
0
        }                        // Required by EF Core

        public Deadline(string aircraftId, string title, decimal?tgtLast, decimal?tgtInit,
                        decimal?tgtInt, DateTime?dateLast, DateTime?dateInit, int?dateInt, DeadlineOptions opts)
        {
            Id                 = Guid.NewGuid();
            AircraftId         = aircraftId;
            Title              = title;
            TargetLastCompl    = tgtLast;
            TargetInit         = tgtInit;
            TargetInterval     = tgtInt;
            DateLastCompl      = dateLast;
            DateInit           = dateInit;
            DateIntervalInDays = dateInt;
            opts.SetId(Id);
            DeadlineOptions = opts;
            Validate();
        }
Beispiel #3
0
 public void Validate()
 {
     // Check for required initial values and required intervals if recurring
     if (DeadlineOptions.TracksDate && !DateInit.HasValue || DeadlineOptions.TracksTarget && !TargetInit.HasValue)
     {
         throw new DeadlineException(Id, "Null initial value(s).");
     }
     if ((DeadlineOptions.TracksDate && DeadlineOptions.IsRecurring) && !DateIntervalInDays.HasValue)
     {
         throw new DeadlineException(Id, "Recurring date set without interval.");
     }
     if ((DeadlineOptions.TracksTarget && DeadlineOptions.IsRecurring) && !TargetInterval.HasValue)
     {
         throw new DeadlineException(Id, "Recurring target without interval.");
     }
     // Validate options
     DeadlineOptions.Validate();
 }