コード例 #1
0
        public async Task <IActionResult> GetMultipleGraphTable(string baseCur, [FromBody] GraphRequestModel checkCur, string date)
        {
            if (checkCur == null)
            {
                return(BadRequest());
            }
            MultipleGraphModel result = await _graphService.GetMultipleGraphData(date, checkCur.rates, baseCur);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
コード例 #2
0
        public async Task <MultipleGraphModel> GetMultipleGraphData(string start, List <string> currencies, string baseCurrency)
        {
            MultipleGraphModel resultModel = new MultipleGraphModel();

            resultModel.BaseCurrencyType = baseCurrency;
            resultModel.GraphsNumb       = currencies.Count;
            resultModel.Rates            = new Dictionary <string, List <double> >();

            foreach (var currency in currencies)
            {
                GraphModel curResult = await GetGraphData(start, currency, baseCurrency);

                resultModel.Rates.Add(currency, curResult.Rates);
                if (resultModel.Dates == null)
                {
                    resultModel.Dates = curResult.Dates;
                }
            }

            return(resultModel);
        }