Beispiel #1
0
        public void LoadDocuments()
        {
            var task = viewModel.LoadDocumentsAsync();

            task.Wait();

            Assert.That(viewModel.Documents.Count, Is.GreaterThan(0));
        }
Beispiel #2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            itemViewModel.LoadAssignmentItemsAsync(assignmentViewModel.SelectedAssignment);

            laborViewModel.LoadLaborHoursAsync(assignmentViewModel.SelectedAssignment);

            photoViewModel.LoadPhotosAsync(assignmentViewModel.SelectedAssignment);

            expenseViewModel.LoadExpensesAsync(assignmentViewModel.SelectedAssignment);

            documentViewModel.LoadDocumentsAsync();

            historyViewModel.LoadHistoryAsync(assignmentViewModel.SelectedAssignment);
        }
        /// <summary>
        /// Sets the child fragment for when each navigation item is selected
        /// </summary>
        private void SetFrameFragment(int index)
        {
            assignment = assignmentViewModel.SelectedAssignment;
            //var transaction = FragmentManager.BeginTransaction ();
            var screen = Constants.Navigation [index];

            switch (screen)
            {
            case "Summary": {
                var fragment = new SummaryFragment();
                fragment.Assignment = assignment;
//                        transaction.SetTransition (FragmentTransit.FragmentOpen);
//                        transaction.Replace (Resource.Id.contentFrame, fragment);
//                        transaction.Commit ();
                items.Visibility        =
                    addItems.Visibility = ViewStates.Invisible;
                addExpense.Visibility   =
                    addLabor.Visibility = ViewStates.Gone;
            }
            break;

            case "Map": {
                var fragment = new MapFragment();
//                        transaction.SetTransition (FragmentTransit.FragmentOpen);
//                        transaction.Replace (Resource.Id.contentFrame, fragment);
//                        transaction.Commit ();
                items.Visibility        =
                    addItems.Visibility = ViewStates.Invisible;
                addExpense.Visibility   =
                    addLabor.Visibility = ViewStates.Gone;
            }
            break;

            case "Items": {
                var fragment = new ItemFragment();
                fragment.Assignment = assignment;
                itemViewModel.LoadAssignmentItemsAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.AssignmentItems = itemViewModel.AssignmentItems;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Visible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                            items.Text = string.Format("({0}) Items", assignment.TotalItems.ToString());
                        });
                    });
            }
            break;

            case "Labor Hours": {
                var fragment = new LaborHourFragment();
                laborViewModel.LoadLaborHoursAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.LaborHours = laborViewModel.LaborHours;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility     =
                                items.Visibility    = ViewStates.Visible;
                            addExpense.Visibility   =
                                addItems.Visibility = ViewStates.Gone;
                            items.Text = string.Format("{0} hrs", assignment.TotalHours.TotalHours.ToString("0.0"));
                        });
                    });
            }
            break;

            case "Confirmations": {
                var fragment = new ConfirmationFragment();
                photoViewModel.LoadPhotosAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Photos     = photoViewModel.Photos;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility     =
                                items.Visibility    = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addItems.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            case "Expenses": {
                var fragment = new ExpenseFragment();
                expenseViewModel.LoadExpensesAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Expenses   = expenseViewModel.Expenses;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            addLabor.Visibility       =
                                addItems.Visibility   = ViewStates.Gone;
                            items.Visibility          =
                                addExpense.Visibility = ViewStates.Visible;
                            items.Text = assignment.TotalExpenses.ToString("$0.00");
                        });
                    });
            }
            break;

            case "Documents": {
                var fragment = new DocumentFragment();
                documentViewModel.LoadDocumentsAsync().ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.Documents = documentViewModel.Documents;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            case "History": {
                var fragment = new HistoryFragment();
                historyViewModel.LoadHistoryAsync(assignment).ContinueWith(_ => {
                        RunOnUiThread(() => {
                            fragment.History    = historyViewModel.History;
                            fragment.Assignment = assignment;
//                                transaction.SetTransition (FragmentTransit.FragmentOpen);
//                                transaction.Replace (Resource.Id.contentFrame, fragment);
//                                transaction.Commit ();
                            items.Visibility        =
                                addItems.Visibility = ViewStates.Invisible;
                            addExpense.Visibility   =
                                addLabor.Visibility = ViewStates.Gone;
                        });
                    });
            }
            break;

            default:
                break;
            }
        }