public static VirkningType Create(DateTime?fromDate, DateTime?toDate)
        {
            if (fromDate.HasValue && toDate.HasValue)
            {
                var effectiveToDate = toDate;

                // If date range boundaries contain no time componenbt
                if (toDate.Value.TimeOfDay.TotalMilliseconds == 0)
                {
                    // Set toDate to end of day
                    effectiveToDate = toDate.Value.AddDays(1).AddMilliseconds(-1);
                }

                if (effectiveToDate < fromDate)
                {
                    throw new ArgumentException(string.Format("fromDate ({0}) should be less than or equal to toDate ({1})", fromDate, toDate));
                }
            }
            return(new VirkningType()
            {
                //TODO: Fill actor
                AktoerRef = null,
                //TODO: Fill comment text
                CommentText = null,
                FraTidspunkt = TidspunktType.Create(fromDate),
                TilTidspunkt = TidspunktType.Create(toDate)
            });
        }
Exemple #2
0
 public VirkningType ToVirkningType()
 {
     return(new VirkningType()
     {
         AktoerRef = UnikIdType.Clone(this.AktoerRef),
         CommentText = this.CommentText,
         FraTidspunkt = TidspunktType.Create(TidspunktType.ToDateTime(this.FraTidspunkt)),
         TilTidspunkt = null
     });
 }
Exemple #3
0
 public static TilstandVirkningType Create(DateTime?fromDate)
 {
     return(new TilstandVirkningType()
     {
         //TODO: Fill actor
         AktoerRef = null,
         //TODO: Fill comment text
         CommentText = null,
         FraTidspunkt = TidspunktType.Create(fromDate)
     });
 }
Exemple #4
0
 public bool DateRangeIncludes(DateTime registrationDate)
 {
     return
         ((
              !TidspunktType.ToDateTime(RegistreringFraFilter).HasValue || RegistreringFraFilter.ToDateTime().Value <= registrationDate
              )
          &&
          (
              !TidspunktType.ToDateTime(RegistreringTilFilter).HasValue || RegistreringTilFilter.ToDateTime().Value >= registrationDate
          ));
 }
 public static DateTime?ToDateTime(TidspunktType value)
 {
     if (value == null)
     {
         return(null);
     }
     else
     {
         return(value.ToDateTime());
     }
 }
 public static bool IsDoubleOpen(VirkningType v)
 {
     if (v == null)
     {
         return(true);
     }
     if (!TidspunktType.ToDateTime(v.FraTidspunkt).HasValue&& !TidspunktType.ToDateTime(v.TilTidspunkt).HasValue)
     {
         return(true);
     }
     return(false);
 }
        public static TidspunktType Create(DateTime?value)
        {
            var ret = new TidspunktType();

            //TODO : Xml element called either Tidsstempel:datetime or GraenseIndikator:bool
            if (value.HasValue)
            {
                ret.Item = value.Value;
            }
            else
            {
                //TODO: is the value of true relevant here? cou
                ret.Item = false;
            }
            return(ret);
        }
        public bool Intersects(VirkningType otherEffect)
        {
            var v1 = VirkningType.Create(this.FraTidspunkt.ToDateTime(), this.TilTidspunkt.ToDateTime());
            var v2 = VirkningType.Create(otherEffect.FraTidspunkt.ToDateTime(), otherEffect.TilTidspunkt.ToDateTime());

            foreach (var v in new VirkningType[] { v1, v2 })
            {
                if (!v.FraTidspunkt.ToDateTime().HasValue)
                {
                    v.FraTidspunkt = TidspunktType.Create(DateTime.MinValue);
                }
                if (!v.TilTidspunkt.ToDateTime().HasValue)
                {
                    v.TilTidspunkt = TidspunktType.Create(DateTime.MaxValue);
                }
            }
            return(v1.FraTidspunkt.ToDateTime().Value < v2.TilTidspunkt.ToDateTime().Value &&
                   v2.FraTidspunkt.ToDateTime().Value < v1.TilTidspunkt.ToDateTime().Value);
        }