Skip to content

Instantly share code, notes, and snippets.

@coreylschneider
Created December 24, 2020 18:10
Show Gist options
  • Save coreylschneider/f64daeeadd164ef2ec99fb954b5f8378 to your computer and use it in GitHub Desktop.
Save coreylschneider/f64daeeadd164ef2ec99fb954b5f8378 to your computer and use it in GitHub Desktop.
public class MajorIndexListingViewModel : ViewModelBase
{
private readonly IMajorIndexService _majorIndexService;
private MajorIndex _BTC;
public MajorIndex BTC
{
get
{
return _BTC;
}
set
{
_BTC = value;
OnPropertyChanged(nameof(BTC));
}
}
private MajorIndex _LTC;
public MajorIndex LTC
{
get
{
return _LTC;
}
set
{
_LTC = value;
OnPropertyChanged(nameof(LTC));
}
}
private MajorIndex _ETH;
public MajorIndex ETH
{
get
{
return _ETH;
}
set
{
_ETH = value;
OnPropertyChanged(nameof(ETH));
}
}
public MajorIndexListingViewModel(IMajorIndexService majorIndexService)
{
_majorIndexService = majorIndexService;
}
public static MajorIndexListingViewModel LoadMajorIndexViewModel(IMajorIndexService majorIndexService)
{
MajorIndexListingViewModel majorIndexViewModel = new MajorIndexListingViewModel(majorIndexService);
majorIndexViewModel.LoadMajorIndexes();
return majorIndexViewModel;
}
private void LoadMajorIndexes()
{
_majorIndexService.GetMajorIndex(CoinbasePro.Shared.Types.ProductType.BtcUsd).ContinueWith(task =>
{
if (task.Exception == null)
{
BTC = task.Result;
}
});
_majorIndexService.GetMajorIndex(CoinbasePro.Shared.Types.ProductType.LtcUsd).ContinueWith(task =>
{
if (task.Exception == null)
{
LTC = task.Result;
}
});
_majorIndexService.GetMajorIndex(CoinbasePro.Shared.Types.ProductType.EthUsd).ContinueWith(task =>
{
if (task.Exception == null)
{
ETH = task.Result;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment