private void Window_Loaded(object sender, RoutedEventArgs e) { DataContext = new DateInformation() { Date = new DateTime(1974, 2, 26) }; }
public PeriodOfActivity(DateInformation date, int registrations, int completions, int evaluations) { DateInformation = date; Registrations = registrations; Completions = completions; Evaluations = evaluations; }
public PeriodOfActivity(DateInformation date, PeriodOfActivity?data) { DateInformation = date; Completions = data?.Completions ?? 0; Evaluations = data?.Evaluations ?? 0; Registrations = data?.Registrations ?? 0; }
public IActionResult Get() { var dateInformation = new DateInformation { Date = DateTime.Now, TimeZone = TimeZoneInfo.Local.Id }; return(Ok(dateInformation)); }
public ActivityDataRowModel( PeriodOfActivity periodOfActivity, string format, DateTime startDate, DateTime endDate ) { Period = DateInformation.GetDateRangeLabel(format, startDate, endDate); Completions = periodOfActivity.Completions; Evaluations = periodOfActivity.Evaluations; Registrations = periodOfActivity.Registrations; }
private static List <Exception> ProcessAndValidateCommon(DateInformation dateInformation, string field) { List <Exception> exceptions = new List <Exception>(); if (dateInformation != null) { bool hasExactFull = dateInformation.DateExact.HasValue; bool hasExactPartial = dateInformation.Year.HasValue || dateInformation.Month.HasValue || dateInformation.Day.HasValue || !string.IsNullOrEmpty(dateInformation.Season) || dateInformation.IsApproximate; bool hasRangeFull = dateInformation.DateMin.HasValue || dateInformation.DateMax.HasValue; bool hasRangePartial = dateInformation.YearMin.HasValue || dateInformation.YearMax.HasValue || dateInformation.MonthMin.HasValue || dateInformation.MonthMax.HasValue || dateInformation.DayMin.HasValue || dateInformation.DayMax.HasValue; bool hasLiteral = !string.IsNullOrEmpty(dateInformation.Literal); List <bool> categories = new List <bool>() { hasExactFull, hasExactPartial, hasRangeFull, hasRangePartial, hasLiteral }; switch (categories.Where(x => x).Count()) { case 0: exceptions.Add(new ArgumentException("A date must have at least one type of field filled out.", field)); break; case 1: // Do Nothing break; default: exceptions.Add(new ArgumentException("A date cannot have more than one type of field filled out.", field)); break; } } else { exceptions.Add(new ArgumentNullException("DateInformation")); } return(exceptions); }