예제 #1
0
        /// <summary>
        /// Set all the toolbar items required for a submitted time entry.
        /// </summary>
        private void setSubmittedEntryToolbarItems()
        {
            if (ViewModel.IsSubmitted())
            {
                // Recall command.
                recallTimeCommand         = ToolbarHelper.createRecallButton();
                recallTimeCommand.Command = new RelayCommandAsync(async() =>
                {
                    // Since the toolbar items cannot be disabled, disable the action if
                    // there is already an action going on in the view model.
                    if (!this.ViewModel.IsBusy)
                    {
                        // No need to disable controls here since this control exists only for non-editable entries.
                        this.ViewModel.IsBusy = true;
                        // If recall finishes correctly, stay on the page since the user probably wants to edit the record.
                        if (await this.ViewModel.Recall())
                        {
                            this.setEditabilityOfControls(ViewModel.CanEdit());
                            this.setEditableEntryToolbarItems();
                            ViewModel.HasPendingDataToSave = false; // This needs to be manually changed here because the status has changed.
                        }
                        else
                        {
                            await MessageCenter.ShowErrorMessage(AppResources.RecallError);
                        }
                        this.ViewModel.IsBusy = false;
                    }
                });

                this.ToolbarItems.Add(recallTimeCommand);
            }
        }
예제 #2
0
        public void IsSubmittedTimeEntryTest()
        {
            msdyn_timeentry timeEntry = new msdyn_timeentry();
            TimeViewModel   entry     = new TimeViewModel(timeEntry);

            Assert.IsFalse(entry.IsSubmitted(), "A time entry that hasn't been saved (has null values) should return false.");

            timeEntry.Id = Guid.NewGuid();
            entry.SetDefaultValues();
            Assert.IsFalse(entry.IsSubmitted(), "A time entry that has been saved with values should return false.");

            timeEntry.msdyn_entryStatus = new OptionSetValue((int)msdyn_timeentry_msdyn_entrystatus.Submitted);
            Assert.IsTrue(entry.IsSubmitted(), "A time entry that has been submitted should return true.");

            timeEntry.msdyn_entryStatus = new OptionSetValue((int)msdyn_timeentry_msdyn_entrystatus.Approved);
            Assert.IsFalse(entry.IsSubmitted(), "A time entry that has been saved with values should return false.");
        }