Ejemplo n.º 1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var accountCore = new AccountCore();

            if (accountType.SelectedItem != null && householdPicker.SelectedItem != null && balance.Text != null &&
                accountName.Text != null && interestRate.Text != null)
            {
                int typeId      = accountTypes.Where(t => t.Key == accountType.SelectedItem.ToString()).FirstOrDefault().Value;
                int householdId = households.Where(t => t.Key == householdPicker.SelectedItem.ToString()).FirstOrDefault().Value;

                int result = await accountCore.CreateAccount(accountName.Text, float.Parse(balance.Text), Convert.ToDecimal(interestRate.Text), typeId, householdId);

                if (result != -1)
                {
                    await DisplayAlert("Failed", "Account not added", "OK");
                }
                else
                {
                    await DisplayAlert("Success", "Account has been added", "OK");

                    await Navigation.PopAsync();
                }
            }
            else
            {
                await DisplayAlert("Failed", "Account not added", "OK");
            }
        }
Ejemplo n.º 2
0
        private async void GetAccountInfo()
        {
            var info        = new CreateAccountViewModel();
            var accountCore = new AccountCore();

            List <string> typeName      = new List <string>();
            List <string> householdName = new List <string>();

            info.accountTypes = await accountCore.GetAccountTypes();

            info.households = await accountCore.GetHouseholds();

            foreach (var item in info.accountTypes)
            {
                accountTypes.Add(item.Name, item.Id);
                typeName.Add(item.Name);
            }

            foreach (var item in info.households)
            {
                households.Add(item.Name, item.Id);
                householdName.Add(item.Name);
            }

            accountType.ItemsSource     = typeName;
            householdPicker.ItemsSource = householdName;
        }
Ejemplo n.º 3
0
        async Task <List <Account> > PopulateList()
        {
            var accountCore = new AccountCore();

            _accountList = await accountCore.GetAccounts();

            return(_accountList);
        }
Ejemplo n.º 4
0
        async void RefreshAccounts()
        {
            var accountCore = new AccountCore();

            List <Account> accounts = await accountCore.GetAccounts();


            ObservableCollection <Account> accountList = new ObservableCollection <Account>();

            foreach (var item in accounts)
            {
                accountList.Add(item);
            }

            lstAccounts.ItemsSource = accountList;
        }
Ejemplo n.º 5
0
        private async void GetAccounts()
        {
            var accountCore = new AccountCore();

            List <Account> accounts = await accountCore.GetAccounts();


            ObservableCollection <Account> accountList = new ObservableCollection <Account>();

            foreach (var item in accounts)
            {
                accountList.Add(item);
            }

            this.BindingContext     = accountList;
            lstAccounts.ItemsSource = accountList;
        }
Ejemplo n.º 6
0
        private async void GetAccount(int accountId)
        {
            var accountViewModel = new AccountViewModel();
            var accountCore      = new AccountCore();

            Account account = await accountCore.GetAccount(accountId);

            accountViewModel.Name           = account.Name;
            accountViewModel.CurrentBalance = account.CurrentBalance;
            accountViewModel.InterestRate   = account.InterestRate;

            AccountType accountType = await accountCore.GetAccountType(account.AccountTypeId);

            accountViewModel.AccountTypeName = accountType.Name;

            Household household = await accountCore.GetHousehold(account.HouseholdId);

            accountViewModel.HouseholdName = household.Name;

            BindingContext = accountViewModel;
        }