Created
December 24, 2020 18:10
-
-
Save coreylschneider/f64daeeadd164ef2ec99fb954b5f8378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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