Ejemplo n.º 1
0
        /// <summary>
        /// This method will first signal the test list page about the new comment and then redirect the user back to test list page
        /// </summary>
        async Task AddComment()
        {
            //do not let the user save when it is currently uploading an image
            if (IsBusy)
            {
                return;
            }
            //make sure the comment is not empty and the user have uploaded an image
            if (String.IsNullOrWhiteSpace(Comment) || ImageUrl == "upload_image")
            {
                await Application.Current.MainPage.DisplayAlert("Reminder", "Please make sure that you have uploaded an image and insert some description", "OK");

                return;
            }
            CommentViewModel newComment = new CommentViewModel(ImageUrl, Comment);
            var result = await taskService.AddDefectReport(_serviceVisitItemNumber, newComment);

            if (result)
            {
                MessagingCenter.Send <TestCommentPageViewModel, CommentViewModel>(this, "AddTestComment", newComment);
                await Application.Current.MainPage.Navigation.PopAsync();
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Something Went Wrong", "An error occurs when trying to add the comment. Please try again", "OK");
            }
        }