Esempio n. 1
0
        //the main Application and its functionalities
        public App()
        {
            AuthenticationService = DependencyService.Get <IRESTService>();
            var rest = new ManagerRESTService(new RESTService());

            // MainPage = new NavigationPage(new LoginPage());
            // NavigateAsync(FirstPage.Login);
            Debug.WriteLine("App testing userloggedIn");
            try
            {
                if (rest.IsAutheticated())
                {
                    Debug.WriteLine("userloggedIn is true");
                    MainPage = new NavigationPage(new AccountsPage());
                }
                else
                {
                    Debug.WriteLine("userloggedIn is false");
                    MainPage = new NavigationPage(new LoginPage());
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 2
0
        //What will happen if the user clicks the confirmation button, the users entry information shall be sent and verified if correct
        //if the result is true then a message shall be displayed afirming that statement else another message shall display that something went wrong
        private async void OnConfirmationButtonClicked(object sender, EventArgs e)
        {
            var rest = new ManagerRESTService(new RESTService());
            //account info to whom i am making the payment to
            var accountTo = new Payments.To
            {
                account_id = _userEntry.Text
            };
            //bankid thats connected to the account specified on top to whom i am making the payment to
            var bankTo = new Payments.To
            {
                bank_id = _bankEntry.Text
            };
            //currency chosen to make the payment
            var currencyTo = new Payments.Value
            {
                currency = _currencyEntry.Text
            };
            //the amount that the user is willing to pay
            var amountTo = new Payments.Value
            {
                amount = _amountEntry.Text
            };
            //a simple description of the transaction
            var descriptionTo = new Payments.Body
            {
                description = _descriptionEntry.Text
            };

            //Sent to the RestService to verify the information received on this page to then be treated
            var result = await rest.MakePayment(accountTo, bankTo, currencyTo, amountTo, descriptionTo);

            Debug.WriteLine("result {0}", result);
            //if the result is false it will stay on the same page and show the message stated else it will change to the next page
            if (result)
            {
                try
                {
                    await DisplayAlert("Confirmed", "Transaction Completed", "Ok");
                }
                catch (Exception err)
                {
                    Debug.WriteLine("Caught error: {0}.", err);
                }
            }
            else
            {
                await DisplayAlert("Alert", "Something happened :(", "OK");
            }
        }
Esempio n. 3
0
        //This function is used to determine what will happen when the user clicks the loginButton
        //The requset is made to determine whether the information is true or false, depending on this it will change to the accountPage or will display an alert
        private async void OnLoginButtonClicked(object sender, EventArgs e)
        {
            var rest = new ManagerRESTService(new RESTService());
            var user = new Users
            {
                User = userEntry.Text,
            };
            var pass = new Users
            {
                Password = passwordEntry.Text
            };

            //checks if the user entry and password entry are empty
            if (userEntry.Text == null || passwordEntry.Text == null)
            {
                userEntry.Text     = String.Empty;
                passwordEntry.Text = String.Empty;
                messageLabel.Text  = String.Empty;
            }
            //Verfication of users information through OpenBanks Direct Login where the user should receive a token
            //this token is never shown to the user, used in background functions to request authorized information for the user
            var result = await rest.CreateSession(user, pass);

            Debug.WriteLine("result {0}", result);
            //if the result is false it will stay on the same page and show the message stated else it will change to the next page
            if (result)
            {
                try
                {
                    //could be passing to much information may have to simplify
                    await Navigation.PushAsync(new AccountsPage());
                }
                catch (Exception err)
                {
                    Debug.WriteLine("Caught error: {0}.", err);
                }
            }
            //Used to display alert if an error occurs
            else
            {
                await DisplayAlert("Alert", "Login Failed", "OK");
            }
        }
Esempio n. 4
0
        //Taking care of bussiness, verifyifing if the information received of the transaction history is correct
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                Debug.WriteLine("Clicked transaction button");
                var uri = String.Format(Constants.MovementUrl, AccountsPage.Bankid, AccountsPage.Accountid);

                //getting information from the online location
                await rest.GetWithToken(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            var result = t.Result;

                            transactionList =
                                JsonConvert.DeserializeObject <TransactionList>(result);

                            dateAscending   = true;
                            amountAscending = true;
                            valueAscending  = true;

                            //used to take out the t and z out of the date information received from OpenBank
                            for (int i = 0; i < transactionList.transactions.Count; i++)
                            {
                                char[] delimiters = new char[] { 'T', 'Z' };

                                var date = transactionList.transactions[i].details.completed.Split(delimiters);
                                var test = string.Join(" ", date);
                                transactionList.transactions[i].details.completed = test;
                            }

                            _listView = new ListView
                            {
                                HasUnevenRows  = true,
                                Margin         = 10,
                                SeparatorColor = Color.Teal,
                                ItemsSource    = transactionList.transactions,
                                ItemTemplate   = new DataTemplate(typeof(TransactionCell))
                            };
                            _listView.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as Transaction);
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy = false;

                Button graphbutton = new Button()
                {
                    Text = "Graphs"
                };
                graphbutton.Clicked += async(sender, args) => await Navigation.PushAsync(new ChartsPage());

                Content = new StackLayout
                {
                    BackgroundColor = Color.Teal,
                    Spacing         = 10,
                    Children        =
                    {
                        menuLayout,
                        labelLayout,
                        _listView,
                        graphbutton
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Internet problems cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 5
0
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                var uri  = string.Format(Constants.BranchesUrl, AccountsPage.Bankid);

                await rest.GetwithoutToken <branchlist>(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            List <Branch> data = t.Result.branches;

                            if (data.Count == 0)
                            {
                                Map = new Map(MapSpan.FromCenterAndRadius(
                                                  new Position(0, 0), Distance.FromMiles(0.5)))
                                {
                                    IsShowingUser   = true,
                                    HeightRequest   = 100,
                                    WidthRequest    = 960,
                                    VerticalOptions = LayoutOptions.FillAndExpand
                                };
                                Map.Pins.Add(new Pin
                                {
                                    Position = new Position(32.6672502, -16.9168688),
                                    Label    = "Nothing over here ",
                                    Address  = "Top Secret Company "
                                });
                                Map.MoveToRegion(MapSpan.FromCenterAndRadius(
                                                     new Position(32.6672502, -16.9168688), Distance.FromMiles(2.0)));
                                Map.Margin = 5;
                            }
                            else
                            {
                                Debug.WriteLine("Latitude {0}--- Longitude{1} ---- name {2}", data[0].location.latitude, data[0].location.longitude, data[0].name);

                                Map = new Map(MapSpan.FromCenterAndRadius(
                                                  new Position(data[0].location.latitude, data[0].location.longitude), Distance.FromMiles(0.5)))
                                {
                                    IsShowingUser   = true,
                                    HeightRequest   = 100,
                                    WidthRequest    = 960,
                                    VerticalOptions = LayoutOptions.FillAndExpand
                                };
                                Map.MoveToRegion(MapSpan.FromCenterAndRadius(
                                                     new Position(data[0].location.latitude, data[0].location.longitude), Distance.FromMiles(1.5)));
                                Map.Margin = 5;
                                for (int i = 0; i < data.Count; i++)
                                {
                                    Map.Pins.Add(new Pin
                                    {
                                        Position = new Position(data[i].location.latitude, data[i].location.longitude),
                                        Label    = "Name: " + data[i].name,
                                        Address  = "Address: " + data[i].address.line_1 + data[i].address.line_2 + data[i].address.line_3 + ";City: " + data[i].address.city + ";State: " + data[i].address.state
                                    });
                                }
                            }
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy  = false;
                Content = new StackLayout
                {
                    Children =
                    {
                        new Label()
                        {
                            Text = "Branches Locations of Bank: " + AccountsPage.Bankid
                        },
                        Map
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Internet problems cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 6
0
        //This function is used to take care of bussiness, receiving the information requseted going through the REST service used to receive information
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                var uri  = String.Format(Constants.AccountUrl);

                //getting information from the online location
                await rest.GetWithToken(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            ListAccounts = JsonConvert.DeserializeObject <Accounts.Account[]>(t.Result);

                            //List used to list information received from the REST service
                            _listView = new ListView
                            {
                                HasUnevenRows  = true,
                                Margin         = 10,
                                SeparatorColor = Color.Teal,
                                ItemsSource    = ListAccounts,
                                ItemTemplate   = new DataTemplate(typeof(AllAccountsCell))
                            };
                            _listView.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as Accounts.Account);
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy = false;

                searchBar.TextChanged         += (sender, e) => FilterBanks(searchBar.Text);
                searchBar.SearchButtonPressed += (sender, e) =>
                {
                    FilterBanks(searchBar.Text);
                };

                //Determinig the new layout containg the information received
                Content = new StackLayout
                {
                    BackgroundColor = Color.Teal,
                    Spacing         = 10,
                    Children        =
                    {
                        menuLayout,
                        searchBar,
                        labelLayout,
                        _listView
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Internet problems cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 7
0
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                var uri  = string.Format(Constants.BankUrl);

                //getting information from the online location
                await rest.GetwithoutToken <Banklist>(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            test = t.Result;

                            _listView = new ListView
                            {
                                HasUnevenRows  = true,
                                Margin         = 10,
                                SeparatorColor = Color.Teal
                            };
                            _listView.ItemsSource  = test.banks;
                            _listView.ItemTemplate = new DataTemplate(typeof(Cells));
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy = false;

                searchBar.TextChanged         += (sender, e) => FilterContacts(searchBar.Text);
                searchBar.SearchButtonPressed += (sender, e) =>
                {
                    FilterContacts(searchBar.Text);
                };

                Content = new StackLayout
                {
                    BackgroundColor = Color.Teal,
                    Spacing         = 10,
                    Children        =
                    {
                        new Label {
                            Text = "Contact list go up and down", HorizontalTextAlignment = TextAlignment.Center
                        },
                        searchBar,
                        _listView
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 8
0
        //Taking care of bussiness, verifyifing if the information received of the transaction history is correct
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                Debug.WriteLine("Clicked transaction button");
                var uri = String.Format(Constants.MovementUrl, AccountsPage.Bankid, AccountsPage.Accountid);

                //getting information from the online location
                await rest.GetWithToken(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            var result = t.Result;

                            Transactions.TransactionList jsonObject =
                                JsonConvert.DeserializeObject <Transactions.TransactionList>(result);

                            foreach (Transactions.Transaction t1 in jsonObject.transactions)
                            {
                                var changevalue = t1.details.value.amount.Replace(".", ",");
                                Debug.WriteLine("changevalue {0}", changevalue);
                                var changebalance = t1.details.new_balance.amount.Replace(".", ",");
                                Debug.WriteLine("changebalance {0}", changebalance);
                                t1.details.value.amount       = changevalue;
                                t1.details.new_balance.amount = changebalance;
                            }

                            List <double> newBalanceList =
                                jsonObject.transactions.Select(x => double.Parse(x.details.new_balance.amount))
                                .ToList();
                            List <double> valueList =
                                jsonObject.transactions.Select(x => double.Parse(x.details.value.amount)).ToList();
                            List <String> completedDateList =
                                jsonObject.transactions.Select(x => x.details.completed).ToList();

                            //Collection of the value amount and the dates of the transactions made
                            ObservableCollection <ChartDataPoint> chartsvalue = new ObservableCollection <ChartDataPoint>();

                            //Collection of the users new balance amounts and the dates of the changes that may have occured
                            ObservableCollection <ChartDataPoint> chartsnewbalance = new ObservableCollection <ChartDataPoint>();

                            //adding the information to each of the charts collections
                            for (var i = 0; i < jsonObject.transactions.Count; i++)
                            {
                                chartsvalue.Add(new ChartDataPoint(completedDateList[i], valueList[i]));
                                Debug.WriteLine("Date :: {0} amount ::{1}", completedDateList[i], valueList[i]);
                                chartsnewbalance.Add(new ChartDataPoint(completedDateList[i], newBalanceList[i]));
                                Debug.WriteLine("Date :: {0} newbalance ::{1}", completedDateList[i], newBalanceList[i]);
                            }
                            Debug.WriteLine("chartsvalue::{0}", chartsvalue.Count);
                            Debug.WriteLine("chartsnewbalance :: {0}", chartsnewbalance.Count);

                            //creates a column series allowing for some animation and for the user to select and see inforamtion
                            chart.Series.Add(new ColumnSeries()
                            {
                                ItemsSource       = chartsnewbalance,
                                Label             = "NewBalance",
                                Color             = Color.Teal,
                                EnableAnimation   = true,
                                AnimationDuration = 0.8,
                                EnableTooltip     = true
                            });

                            //Creates a line series allowing for some animation and for the user to select and see inforamtion
                            chart.Series.Add(new ColumnSeries()
                            {
                                ItemsSource       = chartsvalue,
                                Label             = "Value",
                                Color             = Color.Blue,
                                EnableAnimation   = true,
                                AnimationDuration = 0.8,
                                EnableTooltip     = true
                            });

                            //To show the items used creating a chart legend
                            chart.Legend = new ChartLegend();
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy = false;

                Content = chart;
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Internet problems cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }
Esempio n. 9
0
        //Used to take care of bussiness, to show the accounts detailed information
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                var uri  = string.Format(AccountsPage.Href);

                Debug.WriteLine("uri principalpage {0}", uri);

                if (string.IsNullOrWhiteSpace(uri))
                {
                    Debug.WriteLine("Response contained empty body...");
                }
                else
                {
                    //getting information from the online location about the users detailed account info
                    //in this case it can only get information from one selected account
                    await rest.GetWithToken(uri).ContinueWith(task =>
                    {
                        //Problem occured a message is displayed to the user
                        if (task.IsFaulted)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                DisplayAlert("Alert", "Something went wrong sorry with your detailed information :(", "OK");
                            });
                        }
                        //everything went fine, information should be displayed
                        else
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                AccountInfo.AccountInfoDetailed Information = JsonConvert.DeserializeObject <AccountInfo.AccountInfoDetailed>(task.Result);

                                //label for the number of this account used
                                numberLabel = new Label()
                                {
                                    Text   = "id: " + Information.id,
                                    Margin = 2,
                                    HorizontalTextAlignment = TextAlignment.Center
                                };
                                //this is your balances amount shown
                                amountLabel = new Label()
                                {
                                    Text = "Balance amount: " + Information.balance.amount,
                                    HorizontalTextAlignment = TextAlignment.Center,
                                    BackgroundColor         = Color.Black,
                                    Margin = 2,
                                };
                                //this contains the currency used
                                currencyLabel = new Label()
                                {
                                    Text = "Currency: " + Information.balance.currency,
                                    HorizontalTextAlignment = TextAlignment.Center,
                                    Margin = 2,
                                };
                                //this is the specified bank id
                                bankLabel = new Label()
                                {
                                    Text = "bank: " + Information.bank_id,
                                    HorizontalTextAlignment = TextAlignment.Center,
                                    Margin          = 2,
                                    BackgroundColor = Color.Black
                                };
                                //this is your iban may be empty in some cases
                                ibanLabel = new Label()
                                {
                                    Text   = "IBAN: " + Information.IBAN,
                                    Margin = 2,
                                    HorizontalTextAlignment = TextAlignment.Center
                                };
                                //this is your swift/bic numbers used, may be empty in some cases
                                swiftLabel = new Label()
                                {
                                    Text = "swift/bic: " + Information.swift_bic,
                                    HorizontalTextAlignment = TextAlignment.Center,
                                    Margin          = 2,
                                    BackgroundColor = Color.Black
                                };
                                //this is the type of account that you have, in some cases may be empty
                                typeLabel = new Label()
                                {
                                    Text   = "type: " + Information.type,
                                    Margin = 2,
                                    HorizontalTextAlignment = TextAlignment.Center
                                };

                                //Layout of the accounts detailed information
                                AccountLayout = new StackLayout()
                                {
                                    BackgroundColor = Color.Gray,
                                    Margin          = 10,
                                    Children        = { numberLabel, amountLabel, currencyLabel, bankLabel, ibanLabel, swiftLabel, typeLabel }
                                };
                            });
                        }
                    });
                }
                //indicates the activity indicator that all the information is loaded and ready
                IsBusy  = false;
                Content = new StackLayout
                {
                    BackgroundColor = Color.Teal,
                    Spacing         = 10,
                    Children        =
                    {
                        menuLayout,
                        AccountLayout,
                        ButtonLayout
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "There was a problem sorry :(", "OK");

                Debug.WriteLine("Caught error principalpage: {0}.", err);
            }
        }
Esempio n. 10
0
        //used to take care of bussines to receive the card information of the user// OpenBank contains no known information on this
        private async Task Takingcareofbussiness()
        {
            //trying to get information online if some error occurs this is caught and taken care of, a message is displayed in this case
            try
            {
                //indicates the activity indicator to start
                IsBusy = true;

                var rest = new ManagerRESTService(new RESTService());
                Debug.WriteLine("Clicked transaction button");
                var uri = String.Format(Constants.CardsUrl, AccountsPage.Bankid);

                //getting information from the online location
                await rest.GetWithToken(uri).ContinueWith(t =>
                {
                    //Problem occured a message is displayed to the user
                    if (t.IsFaulted)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayAlert("Alert", "Something went wrong sorry :(", "OK");
                        });
                    }
                    //everything went fine, information should be displayed
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            _listView = new ListView
                            {
                                BackgroundColor = Color.Gray,
                                HasUnevenRows   = true
                            };
                            //Must change this
                            _listView.ItemsSource  = t.Result;
                            _listView.ItemTemplate = new DataTemplate(typeof(Cells));
                        });
                    }
                });

                //indicates the activity indicator that all the information is loaded and ready
                IsBusy  = false;
                Content = new StackLayout
                {
                    BackgroundColor = Color.Teal,
                    Spacing         = 10,
                    Children        =
                    {
                        new Label {
                            Text = "Card list go up and down", HorizontalTextAlignment = TextAlignment.Center
                        },
                        _listView
                    }
                };
            }
            catch (Exception err)
            {
                IsBusy = false;
                await DisplayAlert("Alert", "Internet problems cant receive information", "OK");

                Debug.WriteLine("Caught error: {0}.", err);
            }
        }