/// <summary> /// Changes date that date is not a holiday day and check if endDate is null /// If yes then set value as startDate /// </summary> /// <param name="startDate">start date</param> /// <param name="endDate">end date</param> /// <returns>Tuple of start and end date</returns> public (DateTime StartDate, DateTime EndDate) SetCorrectDate(DateTime startDate, DateTime? endDate) { DateTime startDateTmp = _holidayChecker.ReturnDateBeforeDayOff(startDate); DateTime endDateTmp = endDate ?? startDateTmp; return (startDateTmp, endDateTmp); }
/// <summary> /// Get caches data from database /// </summary> /// <param name="model"><see cref="CurrencyModel"/></param> /// <returns><see cref="IEnumerable{CurrencyValue}"/></returns> public IEnumerable <CurrencyValue> GetAsync(CurrencyModel model) { if (string.IsNullOrWhiteSpace(model.CurrencyBeingMeasured) || string.IsNullOrWhiteSpace(model.CurrencyMatched)) { return(new List <CurrencyValue>()); } var endDate = _holidayChecker.ReturnDateBeforeDayOff(model.EndDate ?? model.StartDate); var results = _dbContext.CurrencyValues.Include(c => c.Currency) .Where(c => (c.DailyDataOfCurrency >= model.StartDate && c.DailyDataOfCurrency <= model.EndDate) && c.Currency.CurrencyBeingMeasured == model.CurrencyBeingMeasured && c.Currency.CurrencyMatched == model.CurrencyMatched); if (!results.Any() || results.Max(r => r.DailyDataOfCurrency) != endDate) { return(new List <CurrencyValue>()); } return(results); }