public async Task AddForecastToCacheAsync(RevenueForecasts forecasts) { var userInfo = await _databaseAccessService.GetUserInfoByForecastId(forecasts.Id.ToString()); var cashedUserInfo = _mapper.Map <CachedUserInfo>(userInfo); var hash = _hashingService.GetHash(cashedUserInfo); await _redisAccessService.SetAsync(await hash, forecasts.Id.ToString(), _cacheExpiryTime); }
private UserInfoToModel PrepareMessageToModel(FullUserInfo fullUserInfo, RevenueForecasts forecast) { var messageToModel = _mapper.Map <UserInfoToModel>(fullUserInfo); messageToModel.ForecastType = forecast.ForecastType.ToString(); messageToModel.RevenueForecastId = forecast.Id.ToString(); return(messageToModel); }
private async Task <string> GetCumulativeChartConfig(RevenueForecasts forecasts) { return(await GetBaseChartConfig( "Revenue (cumulative)", forecasts.ChosenForecast.Monetization, forecasts.ChosenForecast.CumulativeForecast, forecasts.OtherForecasts.Single().Monetization, forecasts.OtherForecasts.Single().CumulativeForecast )); }
private async Task <string> GetTendencyChartConfig(RevenueForecasts forecasts) { return(await GetBaseChartConfig( "Revenue (tendency)", forecasts.ChosenForecast.Monetization, forecasts.ChosenForecast.TendencyForecast, forecasts.OtherForecasts.Single().Monetization, forecasts.OtherForecasts.Single().TendencyForecast )); }
public async Task <RevenueForecasts> CreateForecastAsync(ForecastType forecastType) { var forecast = new RevenueForecasts { IsReady = false, ForecastType = forecastType }; await _forecasts.InsertOneAsync(forecast); return(forecast); }
public async Task <List <Tuple <string, string> > > GetChartUrl(RevenueForecasts forecasts) { var tendencyChartConfig = GetTendencyChartConfig(forecasts); var cumulativeChartConfig = GetCumulativeChartConfig(forecasts); string baseChartUrl = "https://quickchart.io/chart?width=500&height=350&chart="; string tendencyChartUrl = baseChartUrl + Uri.EscapeDataString(await tendencyChartConfig); string cumulativeChartUrl = baseChartUrl + Uri.EscapeDataString(await cumulativeChartConfig); return(new List <Tuple <string, string> > { new Tuple <string, string> ( "TendencyChartUrl", tendencyChartUrl ), new Tuple <string, string> ( "CumulativeChartUrl", cumulativeChartUrl ) }); }