private void SetupViews() { this.expenseControl.tbDescription.Text = this.expenseControl.expense.description; this.expenseControl.tbAmount.Text = this.expenseControl.expense.cost; if (!String.IsNullOrEmpty(this.expenseControl.expense.details) && !this.expenseControl.expense.details.Equals(Expense.DEFAULT_DETAILS)) { this.expenseControl.tbDetails.Text = this.expenseControl.expense.details; } this.expenseControl.expenseDate.Date = DateTime.Parse(this.expenseControl.expense.date, System.Globalization.CultureInfo.InvariantCulture); this.expenseControl.groupList.SelectedItem = GetSelectedGroup(); if (!String.IsNullOrEmpty(this.expenseControl.expense.receipt.large)) { this.expenseControl.receiptImage.Source = new BitmapImage(new Uri(this.expenseControl.expense.receipt.large)); } SetupSelectedUsers(); //setup the payee int payeeCount = 0; Expense_Share payee = null; foreach (var item in this.expenseControl.expense.users) { if (item.hasPaid) { payee = item; payeeCount++; } } if (payeeCount > 1) { this.expenseControl.tbPaidBy.Text = "Multiple users"; this.expenseControl.PaidByUser = null; } else { this.expenseControl.PaidByUser = payee; this.expenseControl.tbPaidBy.Text = payee.ToString(); } //setup the expense to be split unequally for ease of operation this.expenseControl.SplitTypeListPicker.SelectedItem = AmountSplit.UnequalSplit; }
private async Task AddNewPayment() { //only setup the needed details. Expense paymentExpense = new Expense() { payment = true, cost = TransferAmount.ToString(), currency_code = Currency, creation_method = "payment", description = "Payment", details = Details, group_id = (Application.Current as App).PAYMENT_GROUP, users = new List <Expense_Share>() }; Expense_Share fromUser = new Expense_Share(); Expense_Share toUser = new Expense_Share(); if (paymentType == Constants.PAYMENT_TO) { fromUser.user_id = App.currentUser.id; fromUser.owed_share = "0"; fromUser.paid_share = TransferAmount.ToString(); toUser.user_id = paymentUser.id; toUser.paid_share = "0"; toUser.owed_share = TransferAmount.ToString(); } else { toUser.user_id = App.currentUser.id; toUser.paid_share = "0"; toUser.owed_share = TransferAmount.ToString(); fromUser.user_id = paymentUser.id; fromUser.paid_share = TransferAmount.ToString(); fromUser.owed_share = "0"; } paymentExpense.users.Add(fromUser); paymentExpense.users.Add(toUser); ModifyDatabase modify = new ModifyDatabase(_recordPaymentCompleted); await modify.AddExpense(paymentExpense); }