private void EnsureSupportsDedicatedHours(ForecastType forecastType, decimal?dedicatedHours) { if (!forecastType.SupportsDedicatedHours && dedicatedHours.HasValue) { throw new Exception(string.Format("{0} ForecastType on date {1} does not support dedicated hours {2}", forecastType.Name, Date.ToShortDateString(), dedicatedHours)); } }
/// <summary> /// Creates and adds a new forecast based on input /// </summary> /// <param name="date"></param> /// <param name="forecastType"></param> /// <param name="dedicatedHours"></param> public virtual Forecast AddForecast(DateTime date, ForecastType forecastType, decimal?dedicatedHours) { EnsureDate(date); var newItem = new Forecast(date, forecastType, this, dedicatedHours); _forecasts.Add(newItem); return(newItem); }
public Forecast(DateTime date, ForecastType forecastType, ForecastMonth forecastMonth, decimal?dedicatedHours = null) { if (forecastType == null) { throw new Exception("ForecastType can't be null"); } if (forecastMonth == null) { throw new Exception("ForecastMonth can't be null"); } _forecastMonth = forecastMonth; _forecastType = forecastType; _date = date; EnsureSupportsDedicatedHours(forecastType, dedicatedHours); _dedicatedForecastTypeHours = dedicatedHours; }