public Page1() { InitializeComponent(); try { //Process requests: Requests request = new Requests(); //Branches string branchesRequest = request.CreateBranchesRequest(); Data.BranchesResponse bracnhesResponse = request.MakeBranchesRequest(branchesRequest); _viewModel.DataContext.Branches = request.ProcessBranchesResponse(bracnhesResponse); //Queues foreach (Data.Branches branch in _viewModel.DataContext.Branches) { string queuesRequest = request.CreateQueuesRequest(branch.id.ToString()); Data.QueuesResponse queuesResponse = request.MakeQueuesRequest(queuesRequest); if (_viewModel.DataContext.Queues == null) { _viewModel.DataContext.Queues = request.ProcessQueuesResponse(queuesResponse); } else { _viewModel.DataContext.Queues.AddRange(request.ProcessQueuesResponse(queuesResponse)); } } //Visits (must also be able to refresh) foreach (Models.Queue que in _viewModel.DataContext.Queues) { string visitRequest = request.CreateVisitsRequest(que.branchId.ToString(), que.id.ToString()); Data.VisitsResponse visitsResponse = request.MakeVisitsRequest(visitRequest); if (_viewModel.DataContext.Visits == null) { _viewModel.DataContext.Visits = request.ProcessVisitsResponse(que, visitsResponse); } else { _viewModel.DataContext.Visits.AddRange(request.ProcessVisitsResponse(que, visitsResponse)); } } DataContext = _viewModel; } catch (Exception e) { MessageBox.Show(e.Message); } }