Exemplo n.º 1
0
        public override bool ShouldPerformSegue(string segueIdentifier, NSObject sender)
        {
            if (segueIdentifier == "NavigateFromHomeToSubmit")
            {
                float numHoursWorked = AllItemsViewModel.NumberHoursWorkedOnDay();

                if (numHoursWorked < ProjectSettings.NumberHoursInWorkWeek)
                {
                    // The user hasn't worked at least 40 hours this week so display an alert message
                    var alert = UIAlertController.Create(
                        "Are you sure you want to submit your timecard?",
                        string.Format("You have recorded less than {0} hours this week.", ProjectSettings.NumberHoursInWorkWeek),
                        UIAlertControllerStyle.ActionSheet);

                    alert.AddAction(UIAlertAction.Create("Continue", UIAlertActionStyle.Default, (UIAlertAction) =>
                    {
                        PerformSegue("NavigateFromHomeToSubmit", null);
                    }));

                    alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                    PresentViewController(alert, animated: true, completionHandler: null);

                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private async void ConfigureInformationLabels()
        {
            // Sometimes the view may appear while items are still being retrieved from the server.
            // Repeatedly waiting until the items have been retrieved ensures that the hours worked text is correct.
            while (AllItemsViewModel.IsBusy)
            {
                await Task.Delay(150);
            }

            txtHoursWorkedToday.Text    = "Today: " + AllItemsViewModel.NumberHoursWorkedOnDay(DateTime.Now) + " hrs";
            txtHoursWorkedThisWeek.Text = "This Period: " + AllItemsViewModel.NumberHoursWorkedOnDay() + " hrs";

            var startCurrent = ProjectSettings.GetStartOfCurrentPayPeriod().Date;
            var startEntires = AllItemsViewModel.GetStartOfPayPeriod().Date;

            if (startEntires.CompareTo(startCurrent) < 0)
            {
                txtWarningLabel.AdjustsFontSizeToFitWidth = true;
                txtWarningLabel.Text = ViewModel.NeedToSubmitTimecardWarningMessage;
            }
            else
            {
                txtWarningLabel.Text = string.Empty;
            }

            RemoveLoadingIndicator();
        }