private void CheckTimeRange(PerformanceReportType reportType) { int maxTimerange; if (int.TryParse(AppSettings.Get("MobileApi", String.Format("{0}MaxTimeInterval", reportType), false), out maxTimerange)) { var daysDiff = ToDate.Subtract(FromDate).TotalDays; if (maxTimerange > 0 && maxTimerange < daysDiff) { throw new MobileApiException(String.Format("Invalid date parameters, max time interval allowed for report '{1}' is {0} days. To exceed please change in configuration.", maxTimerange, reportType), String.Format("Incorrect Time Selection: Maximum time period for this report is {0} days.", maxTimerange)); } } }