コード例 #1
0
        public JobAcceptanceViewViewModel(object owner)
        {
            parentViewModel = (BaseViewModel)owner;

            if (parentViewModel is ContractorUserControlViewModel)
            {
                var contractorUserControlViewModel = (ContractorUserControlViewModel)parentViewModel;
                this.Job    = contractorUserControlViewModel.GetSelectedJob();
                UserProfile = contractorUserControlViewModel.UserProfile;
            }

            jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this);
            jobService = new JobService();

            AcceptJobCmd = new Xamarin.Forms.Command(async e =>
            {
                if (selectedJob != null)
                {
                    var result = await jobService.AcceptJob(new Model.Requests.AcceptJobRequestRequest
                    {
                        ContractorUUID = UserProfile?.SystemUUID,
                        JobSystemUUID  = selectedJob.SystemUUID
                    });

                    if (result == true)
                    {
                        Navigator.Instance.OkAlert("Job Accepted", "You have accepted the job, please call the requestor for more details.", "OK");
                        await Navigator.Instance.ReturnPrevious(UIPageType.PAGE);
                        if (parentViewModel is ContractorUserControlViewModel)
                        {
                            var contractorUserControlViewModel = (ContractorUserControlViewModel)parentViewModel;
                            await contractorUserControlViewModel.RefreshListAsync();
                        }
                    }
                    else
                    {
                        Navigator.Instance.OkAlert("Error", "There is a problem with the server. Please try again later.", "OK");
                    }
                }
            },
                                                     param =>
            {
                return(true);
            });
        }
コード例 #2
0
        public JobViewViewModel(object owner)
        {
            parentViewModel = (BaseViewModel)owner;

            if (parentViewModel is DashboardUserControlViewModel)
            {
                var dashboardViewModel = (DashboardUserControlViewModel)parentViewModel;
                this.selectedJob = dashboardViewModel.GetSelectedJob();
                UserProfile      = dashboardViewModel.UserProfile;
                SubscribeMeToThis(dashboardViewModel);
            }

            jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this);
            jobService = new JobService();

            EditCmd = new Xamarin.Forms.Command(async e =>
            {
                await Navigator.Instance.NavigateTo(PageType.EDIT_JOB_VIEW, this);
            },
                                                param =>
            {
                return(true);
            });
            DeleteCmd = new Xamarin.Forms.Command(e =>
            {
                Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to delete this job (cannot be undone)?", "Yes", "No", async() =>
                {
                    //For android
                    await DoDeleteJob(selectedJob);
                }, async() =>
                {
                    //For ios
                    await DoDeleteJob(selectedJob);
                });
            },
                                                  param =>
            {
                return(true);
            });
        }
コード例 #3
0
        public JobHistoryViewViewModel(object owner)
        {
            parentViewModel = (BaseViewModel)owner;

            if (parentViewModel is HistoryUserControlViewModel)
            {
                var historyViewModel = (HistoryUserControlViewModel)parentViewModel;
                this.Job = historyViewModel.GetSelectedJob();

                GoToProfilePageCmd = new Xamarin.Forms.Command(async e =>
                {
                    await Navigator.Instance.NavigateTo(PageType.PROFILE_VIEW, this);
                },
                                                               param =>
                {
                    if (param == null)
                    {
                        return(false);
                    }

                    return(!(bool)param);
                });

                string userSystemUUID = "";
                userService = new UserService();
                jobService  = new JobService();
                var user = historyViewModel?.UserProfile;

                if (user != null && this.Job != null)
                {
                    //if the current user is a contractor, and this job is the job that this contractor accepted, the profile displayed would be the job requestor's
                    if (user.IsContractor && this.Job.ContractorSystemUUID == user.SystemUUID)
                    {
                        userSystemUUID = this.Job.RequestorSystemUUID;
                        HasProfile     = true;
                        ProfileType    = Constants.REQUESTOR;
                    }
                    else if (this.Job.RequestorSystemUUID == user.SystemUUID && !string.IsNullOrEmpty(this.Job.ContractorSystemUUID))
                    {
                        //if the job has contractor user uuid assigned (that means the job is accepted by a contractor), then the profile displayed would be contractor's
                        userSystemUUID = this.Job.ContractorSystemUUID;
                        HasProfile     = true;
                        ProfileType    = Constants.CONTRACTOR;

                        if (this.Job.Status != Constants.SUSPENDED && this.Job.Status != Constants.COMPLETED)
                        {
                            ShowFooterButtons = true;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(userSystemUUID))
                {
                    GetProfileData(userSystemUUID);
                }
            }

            jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this);
            SuspendCmd = new Xamarin.Forms.Command(async e =>
            {
                Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to suspend this job?", "Yes", "No", async() =>
                {
                    //For android
                    await DoSuspendJob();
                },
                                                     async() =>
                {
                    //For ios
                    await DoSuspendJob();
                });
            },
                                                   param =>
            {
                if (param == null)
                {
                    return(false);
                }

                return(!(bool)param);
            });
            JobCompletedCmd = new Xamarin.Forms.Command(async e =>
            {
                Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to complete this job?", "Yes", "No", async() =>
                {
                    //For android
                    await DoCompleteJob();
                },
                                                     async() =>
                {
                    //For ios
                    await DoCompleteJob();
                });
            },
                                                        param =>
            {
                if (param == null)
                {
                    return(false);
                }

                return(!(bool)param);
            });
        }