Ejemplo n.º 1
0
        public async Task <AssetForecastModel> GetBitcoinAsync(int valueToApply)
        {
            var uri = $"{API_URL_BASE}&value={valueToApply}";

            AssetForecastModel assetForecast;

            try
            {
                decimal valueInBTC = await _requestProvider.GetAsync <decimal>(uri);

                assetForecast = new AssetForecastModel(
                    Guid.NewGuid(),
                    DateTime.Now,
                    valueInBTC,
                    valueToApply,
                    new AssetModel(Guid.NewGuid(), "BTC", "Bitcoin", "Crypto Currency")
                    );
            }
            catch (HttpRequestExceptionEx exception) when(exception.HttpCode == System.Net.HttpStatusCode.NotFound)
            {
                assetForecast = null;
            }

            return(assetForecast);
        }
Ejemplo n.º 2
0
 public static AssetForecast ConvertToAssetForecastEntity(this AssetForecastModel assetForecastModel) =>
 new AssetForecast(assetForecastModel.Asset.Id, assetForecastModel.Price);