//confirm mpesa received
        private async Task ConfirmPayment()
        {
            var proxy = TinyIoCContainer.Current.Resolve <IConfirmPaymentServiceProxy>();

            using (EnterBusy())
            {
                //Code = "925TDFUZ";
                await Host.ToggleProgressBar(true, res.GetString("VerifyingPayment"));

                var result = await proxy.ConfirmPaymentAsync(Code);

                if (!(result.HasErrors))
                {
                    switch (result.Status)
                    {
                    case "canceled":
                        await Host.ShowAlertAsync(res.GetString("ProceedTransaction"));

                        break;

                    case "error":
                        await Host.ShowAlertAsync(res.GetString("ErrorRequest."));

                        break;

                    case "waiting":
                        await delay5();

                        break;

                    case "success":
                        var toast = new ToastNotificationBuilder(new string[] { res.GetString("PaymentReceived"), res.GetString("WeReceived") });
                        // toast.ImageUri = "ms-appx:///Assets/Toast.jpg";
                        toast.Update();
                        localSettings.Values["Code"] = Code;
                        Host.ShowView(typeof(IViewMaidPageViewModel));
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    errors.CopyFrom(result);
                }

                if (errors.HasErrors)
                {
                    await Host.ShowAlertAsync(errors);
                }

                await Host.ToggleProgressBar(false);
            }
        }
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);
            ErrorBucket errors = new ErrorBucket();

            Items          = new ObservableCollection <TicketItem>();
            SelectedTicket = new TicketItem();
            SubmitCommand  = new DelegateCommand(async(e) =>
            {
                TicketID = (int)e;

                MFundiRuntime.TicketID = TicketID.ToString();

                var proxy = TinyIoCContainer.Current.Resolve <ITaskCompleteServiceProxy>();

                using (EnterBusy())
                {
                    var result = await proxy.TaskCompleteAsync(TicketID);

                    if (!(result.HasErrors))
                    {
                        if (result.Status != "success")
                        {
                            errors.CopyFrom(result);
                        }
                        else
                        {
                            var toast = new ToastNotificationBuilder(new string[] { result.Message });
                            toast.Update();
                            Host.ShowView(typeof(IEvaluationPageViewModel));
                        }
                    }
                    else
                    {
                        errors.CopyFrom(result);
                    }

                    if (errors.HasErrors)
                    {
                        await Host.ShowAlertAsync(errors.GetErrorsAsString());
                    }
                }
            });
        }
Exemple #3
0
        private async void Hire(CommandExecutionContext context)
        {
            // if we don't have a context, create one...
            if (context == null)
            {
                context = new CommandExecutionContext();
            }

            ErrorBucket errors = new ErrorBucket();

            //servicecall
            var proxy = TinyIoCContainer.Current.Resolve <IHireServiceProxy>();

            // call...
            using (EnterBusy())
            {
                await Host.ToggleProgressBar(true, res.GetString("ConfirmExpert"));

                var result = await proxy.HireAsync(ticketID);

                if (!(result.HasErrors))
                {
                    var toast = new ToastNotificationBuilder(new string[] { result.Message });
                    toast.Update();
                    //hired maid so clear ticketid and code
                    ApplicationData.Current.LocalSettings.Values.Remove("Code");
                    ApplicationData.Current.LocalSettings.Values.Remove("TicketID");
                    Host.ShowView(typeof(IHomePageViewModel));
                }
                else
                {
                    errors.CopyFrom(result);
                }

                await Host.ToggleProgressBar(false);
            }
            if (errors.HasErrors)
            {
                await Host.ShowAlertAsync(errors);
            }
        }