コード例 #1
0
        public double GetReportValueByExchangeRate(DateTime StartDate, double DataValue = 0, int Period = 0)
        {
            double   ConvertedValue = DataValue;
            DateTime date = StartDate;
            DateTime MonthStartDate, MonthEndDate = DateTime.Now.Date;

            if (StartDate != null)
            {
                MonthStartDate = GetFirstDayOfMonth(Period, StartDate.Year);
                MonthEndDate   = GetLastDayOfMonth(MonthStartDate.Month, MonthStartDate.Year);
                List <RevenuePlanner.Models.CurrencyModel.ClientCurrency> objReportCache = (List <RevenuePlanner.Models.CurrencyModel.ClientCurrency>)objCache.Returncache(Enums.CacheObject.ListUserReportCurrency.ToString());
                if (objReportCache != null)
                {
                    var GetExchangeRate = objReportCache.Where(a => a.StartDate >= MonthStartDate && a.EndDate <= MonthEndDate)
                                          .Select(a => a)
                                          .FirstOrDefault();
                    if (GetExchangeRate != null)
                    {
                        ConvertedValue = Math.Round((DataValue * GetExchangeRate.ExchangeRate), 2);
                    }
                }
            }
            return(ConvertedValue);
        }