private async void Save_Click(object sender, EventArgs e)
        {
            if (account.PaymentMethods == null || account.PaymentMethods.Count == 0)
            {
                Toast.MakeText(this, "No payment methods are associated with this account. Please create one first.", ToastLength.Short).Show();
            }
            else
            {
                Toast.MakeText(this, "Transaction saved.", ToastLength.Short).Show();
                var model = await GetModel();

                if (model != null)
                {
                    if (account.SavedTransactions == null)
                    {
                        account.SavedTransactions = new List <BsonObjectId>();
                    }
                    account.SavedTransactions.Add(model.Id);
                    ModelMethods.UpdateAccount(account);
                    Return();
                }
                else
                {
                    Toast.MakeText(this, "No recipient found by that User ID.", ToastLength.Short).Show();
                }
            }
        }
        private async void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            BsonObjectId otherid;

            if (transactions.ElementAt(e.Position).SenderID != account.Id)
            {
                otherid = transactions.ElementAt(e.Position).SenderID;
            }
            else
            {
                otherid = transactions.ElementAt(e.Position).RecipientID;
            }
            var otherAccount = await ModelMethods.FindAccountByID(otherid);

            var otherUser = await ModelMethods.FindUserByID(otherAccount.PersonID);

            Intent intent = new Intent(this, typeof(TransactionViewActivity));

            intent.PutExtra("Account", account.ToJson());
            intent.PutExtra("User", user.ToJson());
            intent.PutExtra("Transactions", transactions.ToJson());
            intent.PutExtra("Position", e.Position);
            intent.PutExtra("OtherAccount", otherAccount.ToJson());
            intent.PutExtra("OtherUser", otherUser.ToJson());
            this.StartActivity(intent);
            Finish();
        }
 private void Save_Click(object sender, EventArgs e)
 {
     user.FullName    = FullName.Text;
     user.Username    = Username.Text;
     user.Email       = Email.Text;
     user.PhoneNumber = PhoneNumber.Text;
     ModelMethods.UpdateUserProfile(user);
     Back_To_Profile();
 }
        private void Deny_Click(object sender, EventArgs e)
        {
            var transaction = transactions.ElementAt(position);

            transaction.Accepted = "No";
            ModelMethods.UpdateTransactionAccepted(transaction);
            otherAccount.Balance += transaction.Amount;
            ModelMethods.UpdateAccount(otherAccount);
            Return();
        }
Example #5
0
 private void Save_Click(object sender, EventArgs e)
 {
     model.Description    = Description.Text;
     model.NameOnCard     = NameOnCard.Text;
     model.CardNumber     = CardNumber.Text;
     model.ExpiryDate     = Expiry.Text;
     model.SecurityNumber = SecurityNumber.Text;
     model.ZipCode        = ZipCode.Text;
     ModelMethods.UpdatePaymentMethod(account.PersonID, model);
     Return();
 }
        private async void ViewHistory_Click(object sender, EventArgs e)
        {
            var transactions = await ModelMethods.GetTransactionsInvolvingAccount(account);

            Intent intent = new Intent(this, typeof(TransactionHistoryActivity));

            intent.PutExtra("Account", account.ToJson());
            intent.PutExtra("User", user.ToJson());
            intent.PutExtra("Transactions", transactions.ToJson());
            this.StartActivity(intent);
            Finish();
        }
        private async void Send_Click(object sender, EventArgs e)
        {
            var model = await GetModel();

            if (account.PaymentMethods == null || account.PaymentMethods.Count == 0)
            {
                Toast.MakeText(this, "No payment methods are associated with this account. Please create one first.", ToastLength.Short).Show();
            }
            else if (account.Balance - model.Amount < 0)
            {
                Toast.MakeText(this, "You don't have enough mount to create this transaction.", ToastLength.Short).Show();
            }
            else
            {
                Toast.MakeText(this, "Transaction created.", ToastLength.Short).Show();
                account.Balance -= model.Amount;
                ModelMethods.CreateTransaction(model);
                Return();
            }
        }
        private void BtnRegister_Click(object sender, EventArgs e)
        {
            String FullName    = txtFullName.Text;
            String Username    = txtUsername.Text;
            String Email       = txtEmail.Text;
            String PhoneNumber = PhoneNumberUtils.NormalizeNumber(txtPhoneNumber.Text);
            String Password    = txtPassword.Text;
            String Confirm     = txtConfirmPassword.Text;

            if (Password != Confirm)
            {
                Toast.MakeText(this, "The passwords provided do not match. Please try again.", ToastLength.Short).Show();
            }
            else
            {
                ModelMethods.CreateUser(FullName, Username, Email, PhoneNumber, Password);
                Toast.MakeText(this, "Account created. Please try to login now.", ToastLength.Short).Show();
                Finish();
            }
        }
        private async Task <TransactionModel> GetModel()
        {
            var recipientAccount = await ModelMethods.FindAccountByUserID(Recipient.Text);

            if (recipientAccount != null)
            {
                return(new TransactionModel
                {
                    Description = Description.Text,
                    SenderID = ChangeType.Text == "Send Money" ? recipientAccount.Id : account.Id,
                    RecipientID = ChangeType.Text == "Send Money" ? account.Id : recipientAccount.Id,
                    Memo = Memo.Text,
                    Amount = float.Parse(Amount.Text),
                    DateCreated = DateTime.UtcNow,
                    PaymentMethodID = Adapter[Spinner.SelectedItemPosition].Id
                });
            }
            else
            {
                return(null);
            }
        }
        private void Send_Click(object sender, EventArgs e)
        {
            if (account.PaymentMethods == null || account.PaymentMethods.Count == 0)
            {
                Toast.MakeText(this, "Please add a payment method before depositing or withdrawing.", ToastLength.Short).Show();
                return;
            }
            float change;

            try
            {
                float.TryParse(changed.Text, out change);
            }
            catch
            {
                Toast.MakeText(this, "Invalid change amount.", ToastLength.Short).Show();
                return;
            }
            if (depositwithdraw.Text == "Withdraw" && account.Balance - change < 0)
            {
                Toast.MakeText(this, "You cannot remove more from your account that you have.", ToastLength.Short).Show();
            }
            else
            {
                if (depositwithdraw.Text == "Withdraw")
                {
                    account.Balance -= change;
                }
                else
                {
                    account.Balance += change;
                }
                ModelMethods.UpdateAccount(account);
                Return();
            }
        }
        private async void Refresh_Click(object sender, EventArgs e)
        {
            var PaymentMethods = await ModelMethods.GetPaymentMethods(account.PersonID);

            if (PaymentMethods == null)
            {
                Toast.MakeText(this, "You don't have any payment methods on file. Please add a payment method and try again.", ToastLength.Long).Show();
            }
            else
            {
                sc.Post(new SendOrPostCallback(o => {
                    models.Clear();
                    adapter.NotifyDataSetChanged();
                }), null);
                foreach (var p in PaymentMethods)
                {
                    sc.Post(new SendOrPostCallback(o =>
                    {
                        models.Add(o as PaymentModel);
                        adapter.NotifyDataSetChanged();
                    }), p);
                }
            }
        }
        private void Add_Click(object sender, EventArgs e)
        {
            foreach (var field in fields)
            {
                if (field.Text == String.Empty)
                {
                    Toast.MakeText(this, "Please fill out all fiends before adding payment method.", ToastLength.Short).Show();
                    return;
                }
            }
            PaymentModel model = new PaymentModel
            {
                Description    = description.Text,
                NameOnCard     = nameoncard.Text,
                CardNumber     = number.Text,
                ExpiryDate     = expiry.Text,
                SecurityNumber = security.Text,
                ZipCode        = security.Text
            };

            ModelMethods.AddPaymentMethod(account.PersonID, model);
            Toast.MakeText(this, "Payment method added.", ToastLength.Short).Show();
            Return();
        }
        private async void BtnLogin_Click(object sender, EventArgs e)
        {
            progress.Visibility = ViewStates.Visible;
            String userid   = txtUserID.Text;
            String password = txtPassword.Text;
            var    result   = await ModelMethods.FindUserByUserID(userid);

            progress.Visibility = ViewStates.Invisible;
            if (result != null && result.Password == password)
            {
                var account = await ModelMethods.FindAccountByPersonID(result.Id);

                Toast.MakeText(this, "Login Successful", ToastLength.Short).Show();
                Intent intent = new Intent(this, typeof(MainActivity));
                intent.PutExtra("Account", account.ToJson());
                intent.PutExtra("User", result.ToJson());
                this.StartActivity(intent);
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Login failed.", ToastLength.Short).Show();
            }
        }
Example #14
0
 private void Remove_Click(object sender, EventArgs e)
 {
     ModelMethods.RemovePaymentMethod(account.PersonID, model);
     Return();
 }