コード例 #1
0
 public async Task Deposit()
 {
     await _dialogService.ShowMessage("Are you sure you want to deposit money?",
                                      "Confirmation",
                                      buttonConfirmText : "Yes", buttonCancelText : "No",
                                      afterHideCallback : async(confirmed) =>
     {
         if (confirmed)
         {
             try
             {
                 CurrentUser.Money += MoneyTransaction;
                 MoneyFormat        = CurrentUser.Money + " €";
                 await TransferRecord.AddTransferRecord(MoneyTransaction);
                 await CurrentUser.UpdateUser();
                 await _dialogService.ShowMessage("You have made a deposit to your user account", "Money Transfer");
             }
             catch (DAOException e)
             {
                 await _dialogService.ShowMessage(e.Message, e.Title);
                 CurrentUser.Money -= MoneyTransaction;
                 MoneyFormat        = CurrentUser.Money + " €";
             }
         }
     });
 }
コード例 #2
0
        public async Task Withdraw()
        {
            await _dialogService.ShowMessage("Are you sure you want to withdraw money?",
                                             "Confirmation",
                                             buttonConfirmText : "Yes", buttonCancelText : "No",
                                             afterHideCallback : async(confirmed) =>
            {
                if (confirmed)
                {
                    try
                    {
                        if (CurrentUser.Money - MoneyTransaction < 0)
                        {
                            throw new NotEnoughMoneyException();
                        }

                        CurrentUser.Money -= MoneyTransaction;
                        MoneyFormat        = CurrentUser.Money + " €";
                        await TransferRecord.AddTransferRecord(-MoneyTransaction);
                        await CurrentUser.UpdateUser();
                        await _dialogService.ShowMessage("You withdrawed money from your user account", "Money Transfer");
                    }
                    catch (DAOException e)
                    {
                        await _dialogService.ShowMessage(e.Message, e.Title);
                        CurrentUser.Money += MoneyTransaction;
                        MoneyFormat        = CurrentUser.Money + " €";
                    }
                    catch (NotEnoughMoneyException e)
                    {
                        await _dialogService.ShowMessage(e.Message, e.Title);
                    }
                }
            });
        }