Esempio n. 1
0
 public void AddBalance(decimal additionalBalance, string valute = "GRN")
 {
     if (loggedAccoutUser != null)
     {
         if (valute == "DOL")
         {
             additionalBalance *= 28;
         }
         if (valute == "EUR")
         {
             additionalBalance *= 30;
         }
         try
         {
             if (loggedAccoutUser.Balance == 0 && additionalBalance < 500)
             {
                 FirstDepositeException ex = new FirstDepositeException(string.Format($"Too small first deposit,you have to make first deposit more then 500 {loggedAccoutUser.Valute}"));
                 throw ex;
             }
             else
             {
                 loggedAccoutUser.Balance += additionalBalance;
                 Console.WriteLine($"Congratulations,you`re successfully made a  deposit for {additionalBalance} {loggedAccoutUser.Valute} now you balance is  {loggedAccoutUser.Balance} {loggedAccoutUser.Valute}!");
             }
         }
         catch (FirstDepositeException e)
         {
             Console.WriteLine(e.Message);
         }
     }
     else
     {
         Console.WriteLine("You have to login first");
     }
 }
Esempio n. 2
0
 public void WithdrawMoney(decimal withdrawAmount, string valute = "GRN")
 {
     if (loggedAccoutUser != null)
     {
         if (valute == "DOL")
         {
             withdrawAmount *= 28;
         }
         if (valute == "EUR")
         {
             withdrawAmount *= 30;
         }
         try
         {
             if (loggedAccoutUser.Balance == 0)
             {
                 FirstDepositeException ex = new FirstDepositeException(string.Format($"You have no money on your account,you cant do a withdraw!"));
                 throw ex;
             }
             else if ((loggedAccoutUser.Balance - withdrawAmount) < 0)
             {
                 FirstDepositeException ex = new FirstDepositeException(string.Format($"The withdraw amount is too big,you cant do a withdraw!"));
                 throw ex;
             }
             else
             {
                 loggedAccoutUser.Balance -= withdrawAmount;
                 Console.WriteLine($"Congratulations,you`re successfully withdrawal {withdrawAmount} {loggedAccoutUser.Valute} now you balance is  {loggedAccoutUser.Balance} {loggedAccoutUser.Valute}!");
             }
         }
         catch (FirstDepositeException e)
         {
             Console.WriteLine(e.Message);
         }
     }
     else
     {
         Console.WriteLine("To withdraw money,you have to login first");
     }
 }