コード例 #1
0
        public TaxScheduleValidationResult ValidateTaxSchedule(MunicipalityTaxSchedule tax)
        {
            if (string.IsNullOrWhiteSpace(tax.Municipality))
            {
                return(TaxScheduleValidationResult.MunicipalityInvalid);
            }

            if (tax.ScheduleBeginDate.TimeOfDay.Ticks > 0)
            {
                return(TaxScheduleValidationResult.DateUnsuitableForSchedule);
            }

            if (tax.ScheduleType == ScheduleFrequency.Monthly && tax.ScheduleBeginDate.Day != 1)
            {
                return(TaxScheduleValidationResult.DateUnsuitableForSchedule);
            }

            if (tax.ScheduleType == ScheduleFrequency.Weekly && tax.ScheduleBeginDate.DayOfWeek != DayOfWeek.Monday) // culture invariant first day of week hardcoded to Monday
            {
                return(TaxScheduleValidationResult.DateUnsuitableForSchedule);
            }

            if (tax.ScheduleType == ScheduleFrequency.Yearly && (tax.ScheduleBeginDate.Day != 1 || tax.ScheduleBeginDate.Month != 1))
            {
                return(TaxScheduleValidationResult.DateUnsuitableForSchedule);
            }

            return(TaxScheduleValidationResult.Valid);
        }
コード例 #2
0
 internal MunicipalityTaxDetails FindTaxSchedule(MunicipalityTaxSchedule tax)
 {
     if (tax == null)
     {
         throw new ArgumentNullException(nameof(tax));
     }
     return(database.FirstOrDefault(t => t.MunicipalitySchedule.Equals(tax)));
 }
コード例 #3
0
        public void DeleteTaxSchedule(MunicipalityTaxSchedule tax)
        {
            if (tax == null)
            {
                throw new ArgumentNullException(nameof(tax));
            }
            var existing = FindTaxSchedule(tax);

            if (existing == null)
            {
                throw new InvalidOperationException($"Tax schedule '{tax.DebuggerDisplay}' not found, unable to delete it.");
            }
            database.Remove(existing);
        }
        public TaxScheduleValidationResult ValidateTaxSchedule(MunicipalityTaxSchedule tax)
        {
            if (string.IsNullOrWhiteSpace(tax.Municipality))
            {
                return(TaxScheduleValidationResult.MunicipalityInvalid);
            }

            if (tax.ScheduleBeginDate.TimeOfDay.Ticks > 0)
            {
                return(TaxScheduleValidationResult.DateUnsuitableForSchedule);
            }

            return(TaxScheduleValidationResult.Valid);
        }
コード例 #5
0
 public bool TaxScheduleExists(MunicipalityTaxSchedule tax)
 {
     return(FindTaxSchedule(tax) != null);
 }
コード例 #6
0
        public MunicipalityTaxDetails GetTax(string municipality, DateTime at)
        {
            var results = database.Where(tax => tax.MunicipalitySchedule.Municipality == municipality);

            return(FindTaxSchedule(MunicipalityTaxSchedule.MostApplicable(results.Select(r => r.MunicipalitySchedule), at))); // not the most efficient way to do it ever, but more generic
        }