protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var viewModel = this.DataContext as BranchListViewModel;

            // If viewModel is not null it means that the user navigated back to this page and the viewModel is already loaded.
            if (viewModel == null)
            {
                string selectedIndex = string.Empty;
                string projectName = string.Empty;

                if (this.NavigationContext.QueryString.TryGetValue("projectName", out projectName))
                {
                    viewModel = new BranchListViewModel(string.Format(CultureInfo.InvariantCulture, "Projects('{0}')", projectName));
                }
                else
                {
                    viewModel = new BranchListViewModel();
                }

                if (this.State.ContainsKey("CurrentPageNumber"))
                {
                    viewModel.PageNumber = (int)this.State["CurrentPageNumber"];
                }

                if (this.State.ContainsKey("CurrentQuery"))
                {
                    viewModel.Query = (string)this.State["CurrentQuery"];
                }

                viewModel.LoadData();

                this.DataContext = viewModel;
            }
        }
 private async void OnApiConnectionError(BranchListViewModel viewModel)
 {
     if (await DisplayAlert("Connection error", "Cannot connect to Mobile Center API.", "Configure key", "Cancel"))
     {
         Navigation.PushAsync(new SettingsPage())
     }
 }
        public BranchListPage(Models.App app)
        {
            InitializeComponent();

            // Disable selection on BranchListView items
            BranchListView.ItemSelected += (sender, args) => ((ListView)sender).SelectedItem = null;

            BindingContext = new BranchListViewModel(app);

            // Subscribe to connection error message from the viewModel
            MessagingCenter.Subscribe <BranchListViewModel>(this, Messages.ApiConnectionError, OnApiConnectionError);
        }
        public BranchListViewModel GetPaginatedBranches(List <FilterValue> filterValues, int pageSize, int pageIndex, Guid idAccount)
        {
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Branch, BranchItemViewModel>();
            });
            var itemResult    = new BranchListViewModel();
            var branches      = _branchDao.GetPaginatedBranchesList(filterValues, pageSize, pageIndex, idAccount);
            var countBranches = _branchDao.GetPaginatedBranchesCount(filterValues, pageSize, pageIndex, idAccount);

            itemResult.BranchList = Mapper.Map <List <BranchItemViewModel> >(branches);

            return(ConfigurePagination(itemResult, pageIndex, pageSize, filterValues, countBranches));
        }
        public async Task <IViewComponentResult> InvokeAsync(int partnerId)
        {
            var partner = await _client.GetPartnerAsync(partnerId);

            var contracts = await _client.GetContractsAsync(partnerId);

            var branches = _client.GetBranches(contracts);

            var viewModel = new BranchListViewModel
            {
                Partner  = partner,
                Branches = branches
            };

            return(View(viewModel));
        }
        // GET:Branch List
        public async Task <IActionResult> List()
        {
            var result = await _schoolDataDbContext.Branchs.ToListAsync();

            var branchList = new BranchListViewModel()
            {
                Branches = result
            };

            if (branchList == null)
            {
                ModelState.AddModelError("ListHata", "Model hatası");
                return(RedirectToAction("Index"));
            }
            return(View(branchList));
        }
Exemple #7
0
        public void GetList2()
        {
            BranchListQueryParm parm = new BranchListQueryParm();

            parm.NSRMC          = " ";
            parm.NSRSBH         = " ";
            parm.JYDZ           = " ";
            parm.ZGSWJG         = " ";
            parm.SFNSZT         = -1;
            parm.KYSJ_StartTime = " ";
            parm.KYSJ_EndTime   = " ";
            parm.ZXSJ_StartTime = " ";
            parm.ZXSJ_EndTime   = " ";
            BranchListViewModel model = new BranchListViewModel();
            var grid = model.GetList(parm);

            Assert.AreEqual(113, grid.Rows.Count);
        }
        //Post : Search
        public async Task <IActionResult> Search(string Key)
        {
            if (string.IsNullOrEmpty(Key))
            {
                ModelState.AddModelError(string.Empty, "Id is not unreachable");
                return(View("List"));
            }

            var requireBranches = new BranchListViewModel()
            {
                //Bu kısımda bir açılır kutu görünümü sağlayıp kişilerin aramayı
                //farklı tercihlere göre gerçekleştirebilmesini sağlayabiliriz.

                Branches = await(from m in _schoolDataDbContext.Branchs
                                 where m.BranchName == Key
                                 select m
                                 ).ToListAsync()
            };

            return(View("List", requireBranches));
        }
        public async Task <IActionResult> List(string Key)
        {
            if (string.IsNullOrEmpty(Key))
            {
                ModelState.AddModelError(string.Empty, "Doğru bir arama değeri girmediniz!!");
                return(View());
            }

            // Bu kısımda input değeri değiştikçe arama değerinin değişmesini sağlayan bir method tanımla

            var model = new BranchListViewModel()
            {
                Branches = await _schoolDataDbContext.Branchs.Where(a => a.BranchName.Contains(Key)).ToListAsync()
            };

            if (model == null)
            {
                ModelState.AddModelError(string.Empty, "Can't Find Any People");
                return(View());
            }
            return(View(model));
        }
Exemple #10
0
 public void MyTestInitialize()
 {
     _model = new BranchListViewModel();
 }