public void Set( Report report ) { if ( report == null ) throw new ArgumentNullException( "Report null" ); if ( report.PeriodEnd < report.PeriodStart ) throw new Exception( "End period lower than start period" ); if ( report.PriorPeriodEnd < report.PeriodStart ) throw new Exception( "Prior end period lower than start period" ); if ( report.PriorPeriodEnd < report.PriorPeriodStart ) throw new Exception( "Prior end period lower than prior start period" ); if ( report.PeriodTotal <= 0 ) throw new Exception( "Period total is equal or lower than zero" ); if ( report.PriorPeriodTotal <= 0 ) throw new Exception( "Period total is equal or lower than zero" ); if ( report.PriorPeriodTotal > report.PeriodTotal && string.IsNullOrEmpty( report.ReasonForPeriodDecrease ) ) throw new Exception( "Reason is mandatory when prior period total is greater than period total" ); _reports.Add( report ); }
/* Saves a report to the repository * This method should be modified to perform validation on the report. * This method should also output a message to denote whether the report was saved, or whether there were any validation failures. */ private static void SetReport( Report report ) { _reportRepository.Set( report ); Console.WriteLine( "Saved report with ID: " + report.Id ); }