Skip to content

Instantly share code, notes, and snippets.

@BrianJVarley
Last active December 22, 2015 14:20
Show Gist options
  • Save BrianJVarley/592e3427036b0ce1488a to your computer and use it in GitHub Desktop.
Save BrianJVarley/592e3427036b0ce1488a to your computer and use it in GitHub Desktop.
namespace MongoDBApp.ViewModels
{
[ImplementPropertyChanged]
public class ProductsViewModel
{
private IDataService<ProductModel> _productDataService;
public ProductsViewModel(IDataService<ProductModel> productDataService)
{
this._productDataService = productDataService;
Initialization = GetAllProductsAsync();
}
#region properties
public ObservableCollection<ProductModel> Products { get; set; }
public Task Initialization { get; private set; }
#endregion
#region methods
private async Task GetAllProductsAsync()
{
var productsResult = await _productDataService.GetAllAsync();
Products = productsResult.ToObservableCollection();
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment