Esempio n. 1
0
        /// <summary>
        /// Loads the view-model.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="parameters">Parameters.</param>
        protected override async Task LoadAsync(IDictionary <string, object> parameters)
        {
            try
            {
                InProgress = true;

                // reset the list everytime we load the page
                StockItems.Clear();

                var stockItems = await _stocklistWebServiceController.GetAllStockItems();

                // for all contracts build stock item view model and add to the observable collection
                foreach (var model in stockItems.Select(x =>
                {
                    var model = _stockItemFactory();
                    model.Apply(x);
                    return(model);
                }))
                {
                    StockItems.Add(model);
                }

                InProgress = false;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
            }
        }