Пример #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);
        }
 internal MunicipalityTaxDetails FindTaxSchedule(MunicipalityTaxSchedule tax)
 {
     if (tax == null)
     {
         throw new ArgumentNullException(nameof(tax));
     }
     return(database.FirstOrDefault(t => t.MunicipalitySchedule.Equals(tax)));
 }
        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);
        }
 public bool TaxScheduleExists(MunicipalityTaxSchedule tax)
 {
     return(FindTaxSchedule(tax) != null);
 }
        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
        }