Esempio n. 1
0
        private async void Enter_Click(object sender, System.EventArgs e)
        {
            InputBox.ForeColor = Color.Black;
            DataValidation dv     = new DataValidation();
            var            helper = new BalanceHelper(new UserRepository());

            _user = await helper.GetUserBalance(userId : Domain.Constants.Constants.TestUserId);

            if (dv.ValidateMoneyInput(InputBox.Text))
            {
                switch (InputComboBox.SelectedIndex)
                {
                case 0:
                    helper.AddCashToDb(InputBox.Text, _user);
                    break;

                case 1:
                    helper.AddCardToDb(InputBox.Text, _user);
                    break;
                }
                UpdateIfExist();
            }
            else
            {
                InputBox.ForeColor = Color.Red;
            }
        }
Esempio n. 2
0
        private async void UpdateIfExist()
        {
            var repository  = new UserRepository();
            var helper      = new BalanceHelper(repository);
            var userBalance = await helper.GetUserBalance(Domain.Constants.Constants.TestUserId);

            CashBox.Text = userBalance.Cash.FormatMoney();
            BankBox.Text = userBalance.Card.FormatMoney();
            double total = userBalance.Cash + userBalance.Card;

            TotalBox.Text = total.FormatMoney();
        }
Esempio n. 3
0
        private async void SaveImageClick(object sender, EventArgs e)
        {
            var _userRepository = new UserRepository();
            var helper          = new BalanceHelper(_userRepository);

            _user = await helper.GetUserBalance(userId : Domain.Constants.Constants.TestUserId);

            byte[] file_byte = ImageToByteArray(pictureBox1.Image);
            _user.UserImage = file_byte;
            await _userRepository.Update(_user.Id, _user);

            string text = "Image successfully saved!";

            MessageBox.Show(text);
        }
Esempio n. 4
0
        public async void UpdateInfo()
        {
            var _userRepository = new UserRepository();
            var helper          = new BalanceHelper(_userRepository);

            _user = await helper.GetUserBalance(userId : Domain.Constants.Constants.TestUserId);

#pragma warning disable CS0472
            if (_user.Cash + _user.Card != null)
            {
                textBox1.Text = (_user.Cash + _user.Card).FormatMoney();
            }
            if (_user.UserImage != null)
            {
                pictureBox1.Image = ByteArrayToImage(_user.UserImage);
            }
            await _userRepository.Update(_user.Id, _user);
        }