Esempio n. 1
0
        static void Main(string[] args)
        {
            // hardcode (i just didnt want to think about db or any files with data =) )
            Account acc1 = Account.CreateAccount(100, "uah");  // id 1
            Account acc2 = Account.CreateAccount(5454, "uah"); //   2
            Account acc3 = Account.CreateAccount(200, "usd");  //   .
            Account acc4 = Account.CreateAccount(123, "uah");  //   .
            Account acc5 = Account.CreateAccount(1, "usd");
            Account acc6 = new Account();                      // this acc is not added to bank system initially
            Account acc7 = new Account();

            //  so we add explisitly
            BankSystem.AddAccounts(new Account[] { acc6, acc7 });

            // head od hierarchy
            // basic user with no power
            User basicUser = new User(1, "Andrii", "Koval", "login", "password");

            //bank client is able to have bank accounts
            Console.WriteLine("---------------------Creatinh Bank Client");
            BankClient client = BankClient.CreateBankClient();

            Console.WriteLine("---------------------Creatinh Bank Client");

            // a piece of hardcode (((
            client.AddAccountId(acc1.id);
            client.AddAccountId(acc3.id);
            client.AddAccountId(acc5.id);
            client.ShowInfo();

            Console.WriteLine("---------------------Creatinh Bank Exmployee");
            BankEmployee employee = BankEmployee.CreateBankEmployee();

            Console.WriteLine("---------------------Creating Bank Exmployee");

            BankSystem.AddUser(employee);
            BankSystem.AddUser(client);
            BankSystem.AddUser(basicUser);


            Console.WriteLine("\n------------------------------------All users in system");
            foreach (var user in BankSystem.Users.Values)
            {
                user.ShowInfo();
            }
            Console.WriteLine("------------------------------------All users in system\n");

            acc1.IncreaseAmount(100);
            acc3.IncreaseAmount(100);
            acc5.DecreaseAmount(50000);
            client.ShowInfo("CLIENT OVERRIDEN METHOD", "CLIENT OVERRIDEN METHOD");


            Console.WriteLine(employee.systemUsersCount);
        }
        private async void BtnRegister_Clicked(object sender, EventArgs e)
        {
            if (viewModel.Bank == null)
            {
                await Shell.Current.DisplayAlert("", Language.vui_long_chon_ngan_hang, Language.dong);

                return;
            }
            if (viewModel.Province == null)
            {
                await Shell.Current.DisplayAlert("", Language.vui_long_chon_tinh_thanh, Language.dong);

                return;
            }
            loadingPopup.IsVisible = true;

            BankEmployee bankEmployee = new BankEmployee();

            bankEmployee.BankId     = viewModel.Bank.Id;
            bankEmployee.ProvinceId = viewModel.Province.Id;
            if (viewModel.District != null)
            {
                bankEmployee.DistrictId = viewModel.District.Id;
                bankEmployee.Address    = viewModel.District.Name + ", " + viewModel.Province.Name;
            }
            else
            {
                bankEmployee.Address = viewModel.Province.Name;
            }

            ApiResponse apiResponse = null;

            if (viewModel.Id == Guid.Empty)
            {
                apiResponse = await ApiHelper.Post(ApiRouter.BANK_EMPLOYEE_REGISTER, bankEmployee, true);
            }
            else
            {
                bankEmployee.Id = viewModel.Id;
                apiResponse     = await ApiHelper.Put(ApiRouter.BANK_EMPLOYEE_UPDATE, bankEmployee, true);
            }

            if (apiResponse.IsSuccess)
            {
                OnSaved?.Invoke(this, EventArgs.Empty);
                loadingPopup.IsVisible = false;
            }
            else
            {
                loadingPopup.IsVisible = false;
                await Shell.Current.DisplayAlert("", apiResponse.Message, Language.dong);
            }
        }
Esempio n. 3
0
        private static void MainDemo()
        {
            var acc1 = new Account(100, "uah");  // id 1
            var acc2 = new Account(5454, "uah"); //   2
            var acc3 = new Account(200, "usd");  //   .
            var acc4 = new Account(1, "usd");


            try
            {
                acc1.Activate("Bank228");
                acc2.Activate("Bank228");
                acc3.Activate("Bank228");
                acc4.Activate("WorngPass");
            }
            catch
            {
            }



            Console.WriteLine("---------------------Creating Bank Client");
            BankClient client  = BankClient.CreateBankClient();
            BankClient client2 = BankClient.CreateBankClient();

            Console.WriteLine("---------------------Creating Bank Client");


            client.AddAccountId(acc1.id);
            client.AddAccountId(acc3.id);
            client.ShowInfo();

            Console.WriteLine("---------------------Creating Bank Exmployee");
            var employee = BankEmployee.CreateBankEmployee();

            Console.WriteLine("---------------------Creating Bank Exmployee");

            User basicUser = new User("Andrii", "Koval", "login", "password");

            BankSystem.AddUser(employee);
            BankSystem.AddUser(client);
            BankSystem.AddUser(client2);
            BankSystem.AddUser(basicUser);
        }
        public async void InitUpdate()
        {
            btnRegister.Text = Language.luu;
            var response = await ApiHelper.Get <BankEmployee>(ApiRouter.BANK_EMPLOYEE_DETAIL + viewModel.Id);

            if (response.IsSuccess)
            {
                await Task.WhenAll(viewModel.LoadBanks(), viewModel.GetProvinceAsync());

                BankEmployee emp = response.Content as BankEmployee;
                viewModel.Bank     = emp.Bank;
                viewModel.Province = this.viewModel.ProvinceList.SingleOrDefault(x => x.Id == emp.ProvinceId);
                await viewModel.GetDistrictAsync();

                if (emp.DistrictId.HasValue)
                {
                    viewModel.District = this.viewModel.DistrictList.SingleOrDefault(x => x.Id == emp.DistrictId.Value);
                }
            }
            loadingPopup.IsVisible = false;
        }
 public void AddAdditionalClause(BankEmployee employee, Clause clause)
 {
     AddEvent(new AdditionalClauseAdded(employee, clause));
 }
Esempio n. 6
0
 public void WithdrawMoney(BankEmployee frontLineStaff, decimal amount)
 {
     frontLineStaff.HandleWithdrawRequest(this, amount);
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var acc1 = new Account(100, "uah");  // id 1
            var acc2 = new Account(5454, "uah"); //   2
            var acc3 = new Account(200, "usd");  //   .
            var acc4 = new Account(1, "usd");

            acc1.Activate("Bank228");
            acc2.Activate("Bank228");
            acc3.Activate("Bank228");
            acc4.Activate("WorngPass");


            Console.WriteLine("---------------------Creating Bank Client");
            BankClient client  = BankClient.CreateBankClient();
            BankClient client2 = BankClient.CreateBankClient();

            Console.WriteLine("---------------------Creating Bank Client");


            client.AddAccountId(acc1.id);
            client.AddAccountId(acc3.id);
            client.ShowInfo();

            Console.WriteLine("---------------------Creating Bank Exmployee");
            var employee = BankEmployee.CreateBankEmployee();

            Console.WriteLine("---------------------Creating Bank Exmployee");

            User basicUser = new User("Andrii", "Koval", "login", "password");

            BankSystem.AddUser(employee);
            BankSystem.AddUser(client);  //1
            BankSystem.AddUser(client2); //2
            BankSystem.AddUser(basicUser);

            User user2 = new User("Bodia", "bogdan", "log", "pass");
            User user3 = new User("3", "3", "3", "3");

            User[] IComparableDemoArray = new User[] {
                basicUser,
                user3,
                user2
            };

            Array.Sort(IComparableDemoArray);
            Console.WriteLine("Sorting demo");
            foreach (User user in IComparableDemoArray)
            {
                user.ShowInfo();
            }
            Console.WriteLine("Sorting demo");


            // var foundUser = BankSystem.Users["a"];
            // if (foundUser != null)
            //     Console.WriteLine(foundUser.FullName);


            //extension
            Console.WriteLine(BankSystem.Users.GetBankClientsCount());

            SerializationDemoXML();
            SerializationDemoJSON();

            var obj = new CustomGeneric <BankEmployee>(employee);

            obj.getAllPossibilities();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var acc1 = new Account(100, "uah");  // id 1
            var acc2 = new Account(5454, "uah"); //   2
            var acc3 = new Account(200, "usd");  //   .
            var acc4 = new Account(1, "usd");

            acc1.Activate("Bank228");
            acc2.Activate("Bank228");
            acc3.Activate("Bank228");

            acc4.Activate("WorngPass");

            // head od hierarchy
            // basic user with no power
            User basicUser = new User("Andrii", "Koval", "login", "password");

            //bank client is able to have bank accounts
            Console.WriteLine("---------------------Creating Bank Client");
            BankClient client = BankClient.CreateBankClient();

            Console.WriteLine("---------------------Creating Bank Client");

            // a piece of hardcode (((
            client.AddAccountId(acc1.id);
            client.AddAccountId(acc3.id);
            client.ShowInfo();

            Console.WriteLine("---------------------Creating Bank Exmployee");
            var employee = BankEmployee.CreateBankEmployee();

            Console.WriteLine("---------------------Creating Bank Exmployee");

            BankSystem.AddUser(employee);
            BankSystem.AddUser(client);
            BankSystem.AddUser(basicUser);

            employee.ShowPossibleSystemActions();
            client.ShowPossibleSystemActions();


            Console.WriteLine("\n------------------------------------All users in system");
            foreach (var user in BankSystem.Users.Values)
            {
                user.ShowInfo();
            }
            Console.WriteLine("------------------------------------All users in system\n");

            acc1.IncreaseAmount(100);
            acc3.IncreaseAmount(100);
            acc4.DecreaseAmount(550000);
            client.ShowInfo("CLIENT OVERRIDEN METHOD", "CLIENT OVERRIDEN METHOD");
            try
            {
                Console.WriteLine(employee.SystemUsersCount);
            }
            catch (EmployeeAccessException exp)
            {
                Console.WriteLine("Error");
                Console.WriteLine(exp.args.Message);
            }

            try
            {
                employee.TakeCredit(45);
            }
            catch (EmployeeAccessException exp)
            {
                Console.WriteLine(exp.Message);
            }

            try
            {
                employee.ExchangeMoney(45, 5, 545);
            }
            catch (EmployeeAccessException exp)
            {
                Console.WriteLine(exp.Message);
            }
        }