public DiscountViewModel(IUnitOfWork _unitOfWork, ConnectionPath _connectionpath, SearchViewModel _searchViewModel, IEventAggregator _eventAggregator, User _currentUser)
 {
     unitOfWork      = _unitOfWork;
     connectionpath  = _connectionpath;
     searchViewModel = _searchViewModel;
     eventAggregator = _eventAggregator;
     currentUser     = _currentUser;
     try
     {
         Discounts.AddRange(unitOfWork.GetDiscounts);
     }
     catch (AggregateException e)
     {
         SendMessage(InformationToUser.ServerError);
         Cancel();
         return;
     }
 }
Пример #2
0
        protected void Load(bool refresh)
        {
            if (!refresh && Discounts.Count > 0)
            {
                IsLoading = false;
                return;
            }

            IsLoading = true;

            Task.Factory.StartNew(() =>
            {
                Discounts.Clear();
                Discounts.AddRange(DiscountService.GetDiscounts());
            }).ContinueWith(t =>
            {
                Execute.OnUIThread(() =>
                {
                    IsLoading = false;
                });
            });
        }