Skip to content

Instantly share code, notes, and snippets.

@BrianJVarley
Created December 16, 2015 00:16
Show Gist options
  • Save BrianJVarley/0426cfb18f7c55d0ff3d to your computer and use it in GitHub Desktop.
Save BrianJVarley/0426cfb18f7c55d0ff3d to your computer and use it in GitHub Desktop.
namespace MongoDBApp.ViewModels
{
[ImplementPropertyChanged]
public class CustomerDetailsViewModel : IPageViewModel, IAsyncInitialization
{
public CustomerDetailsViewModel(IDataService<CustomerModel> customerDataService, IDataService<Country> countryDataService, IDialogService dialogService)
{
this._customerDataService = customerDataService;
this._countryDataService = countryDataService;
this._dialogService = dialogService;
Initialization = GetAllCustomersAsync();
IsEnabled = true;
}
#region Properties
public CustomerModel SelectedCustomer { get; set; }
public ObservableCollection<CustomerModel> Customers { get; set; }
public ObservableCollection<Country> Countries { get; set; }
public Task Initialization { get; private set; }
private async Task GetAllCustomersAsync()
{
var customerResult = await _customerDataService.GetAllAsync();
Customers = customerResult.ToObservableCollection();
var countryResult = await _countryDataService.GetAllAsync();
Countries = countryResult.ToObservableCollection();
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment