Ejemplo n.º 1
0
        public void DisplayData()
        {
            RegionDataLoading = true;

            RegionListResponse response = new RegionSQLiteRepository()
                                          .GetRegionsByPage(MainWindow.CurrentCompanyId, RegionSearchObject, currentPage, itemsPerPage);

            if (response.Success)
            {
                RegionsFromDB = new ObservableCollection <RegionViewModel>(response.Regions ?? new List <RegionViewModel>());
                totalItems    = response.TotalItems;
            }
            else
            {
                RegionsFromDB           = new ObservableCollection <RegionViewModel>();
                totalItems              = 0;
                MainWindow.ErrorMessage = response.Message;
            }

            int itemFrom = totalItems != 0 ? (currentPage - 1) * itemsPerPage + 1 : 0;
            int itemTo   = currentPage * itemsPerPage < totalItems ? currentPage * itemsPerPage : totalItems;

            PaginationDisplay = itemFrom + " - " + itemTo + " od " + totalItems;

            RegionDataLoading = false;
        }
        private void PopulateFromDb(string filterString = "")
        {
            Application.Current.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(() =>
            {
                if (CurrentCountry != null)
                {
                    //new RegionSQLiteRepository().Sync(regionService);

                    RegionListResponse regionResp = new RegionSQLiteRepository().GetRegionsForPopup(MainWindow.CurrentCompanyId, CurrentCountry.Identifier, filterString);
                    if (regionResp.Success)
                    {
                        RegionsFromDB = new ObservableCollection <RegionViewModel>(regionResp.Regions ?? new List <RegionViewModel>());
                    }
                    else
                    {
                        RegionsFromDB = new ObservableCollection <RegionViewModel>();
                    }
                }
                else
                {
                    RegionsFromDB = new ObservableCollection <RegionViewModel>();
                }
            })
                );
        }