public void TestWithdrawFromAccount_InvalidAccount()
 {
     MockLogging mockLogging = new MockLogging();
     MockBank mockBank = new MockBank("123123", 600);
     BankAccount b = new BankAccount("123123-Invalid", mockLogging, mockBank);
     Assert.That(() => b.Withdraw(500), Throws.ArgumentException);
 }
 public void TestInsufficientBalance()
 {
     BankAccount account = new BankAccount();
     // If you don't take the Limit down you will get a ContractException by -> balance>=Limit of field balance
     account.Limit = -5;
     account.Debit(10);
 }
 public void Setup()
 {
     _bankAccount = new BankAccount();
     _printer = new FakePrinter();
     DateTimeProvider.SetACustomDateTimeProvider(
         new ConstantDateTimeProvider(new DateTime(2016, 1, 1)));
 }
 public void TestWithdrawFromAccount_NotEnoughMoney()
 {
     MockLogging mockLogging = new MockLogging();
     MockBank mockBank = new MockBank("123123", 400);
     BankAccount b = new BankAccount("123123", mockLogging, mockBank);
     Assert.That(()=>b.Withdraw(500), Throws.ArgumentException);
 }
        public void Given_a_bank_account_when_notified_of_an_event_it_does_not_expect_nor_support_then_expect_a_throw()
        {
            var model = new BankAccount();
            var handler = new ConventionEventHandler(model);

            Assert.Throws<InvalidOperationException>(() => handler.OnNext(new InvalidEventArgs()));
        }
Exemple #6
3
 static void PrintAccInfo(ref BankAccount acc)
 {
     Console.WriteLine("===Account information===");
     Console.WriteLine("№: {0}", acc.accNo);
     Console.WriteLine("balance: {0}$", acc.accBal);
     Console.WriteLine("status: {0}", acc.accType);
 }
    public void Returns_empty_balance_after_opening()
    {
        var account = new BankAccount();
        account.Open();

        Assert.That(account.GetBalance(), Is.EqualTo(0));
    }
Exemple #8
3
        static void Main(string[] args)
        {

            BankAccount checking = new BankAccount();


            BankAccount savings = new BankAccount("S12", "Nar", "Kodavati", 1000);
            Console.WriteLine("{0} {1}, Account : {2}, Balance {3}", savings.FirstName, savings.LastName, savings.AccountNumber, savings.Balance);

        }
        public static Transaction EntityToModel(this entity.Entry item)
        {
            var transaction = new Transaction();
            transaction.Description = item.Memo;
            transaction.Name = item.Name;
            transaction.DateAvailable = item.DateAvailable;
            transaction.DatePosted = item.DatePosted;
            transaction.SpecificSymbol = item.SpecificSymbol.ToString();
            transaction.VariableSymbol = item.VariableSymbol.ToString();
            transaction.ConstantSymbol = item.ConstantSymbol.ToString();
            var accountNumber = item.DestinationAccount.AccountNumber;
            var bankAccount = new BankAccount();
            if (accountNumber != null && accountNumber != 0)
            {
                bankAccount.AccountNumber =
                    accountNumber.Value;
                if (item.DestinationAccount.Bank != null)
                {

                    bankAccount.BankCode = item.DestinationAccount.Bank.BankCode;
                    bankAccount.BankName = item.DestinationAccount.Bank.Name;
                }
                transaction.BankAccount = bankAccount;
            }
            transaction.BankAccount = bankAccount;
            var transactionAmount = new TransactionAmount();
            transactionAmount.Amount = item.AmountInfo.Amount;
            transactionAmount.Currency = item.AmountInfo.Currency;
            if (item.PaymentType != null)
                transactionAmount.PaymentType = item.PaymentType.Name;
            transactionAmount.TransactionType = item.AmountInfo.Type.TypeName;
            transaction.TransacionAmount = transactionAmount;
            return transaction;
        }
 public DirectDebitInitiationContract(BankAccount creditorAccount, string nIF, string creditorBusinessCode, CreditorAgent creditorAgent)
 {
     this.creditorAccount = creditorAccount;
     this.creditorBusinessCode = creditorBusinessCode;
     GenerateCreditorID(nIF,creditorBusinessCode);
     this.creditorAgent = creditorAgent;
 }
    protected void Submit_Click(object sender, EventArgs e)
    {
        CleanUpInput();
        // 1) Create an object to hold information from the user.
        if(IsValid && OtherValidation())
        {
        BankAccount Account;
        Account = new BankAccount();

        // 2) Take the info the user entered into the form and put it in the object
        Account.AccountHolder = AccountHolder.Text;
        Account.AccountNumber = Convert.ToInt32(AccountNumber.Text);
        Account.Openingbalance = Convert.ToDouble(OpeningBalance.Text);
        Account.OverDraftLimit = Convert.ToDouble(OverdraftLimit.Text);
        Account.AccountType = AccountType.SelectedValue;

        // 3) Do something with the object
        // Put the output on the webpage, just to show that we were able to create an object
        ShowTheFormResult(Account);

        //add the new account to my StoredData and then display it in the GridView
        StoredData.Add(Account);
        BankAccountsGridView.DataSource = StoredData;// give the gridview the data
        BankAccountsGridView.DataBind(); //tell teh gridview to extract data fro display
        }
    }
 public void New(string username, string password, decimal openingBalance)
 {
     BankAccount ba = new BankAccount();
     ba.AccountBalance = openingBalance;
     ba.Password = password;
     ba.Username = username;
     func.newAccount(ba);
 }
Exemple #13
1
 static void Main(string[] args)
 {
     BankAccount bank = new BankAccount();
     bank.accountName = "Student saver";
     bank.setBalance(5);
     System.Console.WriteLine(5.GetType()) //print out Int
     System.Console.WriteLine(bank.GetBalance());
     System.Console.ReadLine();
 }
Exemple #14
0
 public void TransferFrom(BankAccount target, decimal summ)
 {
     if (Withdraw(summ))
     {
         target.AddDeposit(summ);
     }
 }
Exemple #15
0
    public void TransferFrom(BankAccount otherAcct, double amt)
    {
        Console.WriteLine("[{0}] Transfering {1:C0} from account {2} to {3}",
                          Thread.CurrentThread.Name, amt,
                          otherAcct.AccountNumber, this.AccountNumber);

        Mutex[] locks = {_lock, otherAcct._lock};
        if (WaitHandle.WaitAll(locks))
        {
            try
            {
                Thread.Sleep(100);
                otherAcct.Debit(amt);
                this.Credit(amt);
            }
            finally
            {
                foreach (Mutex mutexLock in locks)
                {
                    mutexLock.ReleaseMutex();
                }
            }

        }
    }
 public void ShowTheFormResult(BankAccount AccountObject)
 {
     string linebreak = "<br />";
     FormResults.Text = "the following objecct was created:" + linebreak + "Person: " +
         AccountObject.AccountHolder + linebreak + "Balance: " + AccountObject.Openingbalance.ToString() +
         linebreak + "Type: " + AccountObject.AccountType;
 }
Exemple #17
0
 public static int InsertIntoOringalTransaction(BankAccount bankAccount, Transaction transaction, string categoryName)
 {
     string cmdText = "INSERT INTO tblOrginalTransaction(";
     cmdText += "Verified, TransactionID, TransactionDate, TransactionAmount, Merchant, BankMemo, BankAccountId, TransactionType";
     if (!string.IsNullOrEmpty(transaction.CheckNumber))
         cmdText += ", CheckNumber";
     if (categoryName != "")
         cmdText += ", CategoryName";
     cmdText += ") Values(";
     cmdText += "false";
     cmdText += ", '" + transaction.TransactionID + "'";
     cmdText += ", #" + Convert.ToString(transaction.TransactionDate) + "#";
     cmdText += ", " + Convert.ToString(transaction.TransactionAmount);
     cmdText += ", '" + transaction.MerchantName.Replace(@"'", "''") + "'";
     cmdText += ", '" + transaction.BankMemo.Replace(@"'", "''") + "'";
     cmdText += ", " + Convert.ToString(bankAccount.BankAccountID);
     cmdText += ", '" + transaction.TransactionType + "'";
     if (!string.IsNullOrEmpty(transaction.CheckNumber))
         cmdText += ", '" + transaction.CheckNumber + "'";
     if (categoryName != "")
         cmdText += ", '" + categoryName + "'";
     cmdText += ")";
     string identity = " SELECT @@Identity";
     int orginalTransactionID;
     using (OleDbConnection myConnection = new OleDbConnection(
     ConfigurationManager.ConnectionStrings["BeanCounterDB"].ToString()))
     {
         myConnection.Open();
         using (OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection))
             myCommand.ExecuteNonQuery();
         using (OleDbCommand myCommand = new OleDbCommand(identity, myConnection))
             orginalTransactionID = Convert.ToInt32(myCommand.ExecuteScalar().ToString());
     }
     return orginalTransactionID;
 }
Exemple #18
0
 static void Write(BankAccount toWrite, string name)
 {
     Console.WriteLine(name);
     Console.WriteLine("Account number is {0}",  toWrite.GetAccNo());
     Console.WriteLine("Account balance is {0}", toWrite.GetAccBal());
     Console.WriteLine("Account type is {0}", toWrite.GetAccType());
     Console.WriteLine();
 }
        public void WithDrawalTest()
        {
            IBankAccount newAccount = new BankAccount(false);
            newAccount.Deposit(100);
            newAccount.WithDraw(90);

            Assert.AreEqual(newAccount.GetBalance(), 10);
        }
        public void MaxWithDrawalTest()
        {
            IBankAccount newAccount = new BankAccount(true);
            newAccount.Deposit(10001);
            newAccount.WithDraw(10002);

            Assert.AreEqual(newAccount.GetBalance(), -1);
        }
 public void TestPositiveDebit()
 {
     BankAccount account = new BankAccount();
     // If you don't take the Limit down you will get a ContractException by -> balance>=Limit of field balance
     account.Limit = -5;
     account.Debit(5);
     Assert.AreEqual(account.Balance, -5);
 }
Exemple #22
0
 public Average(BankAccount bank , int fromDate , int toDate)
 {
     begDate = fromDate;
     endDate = toDate;
     untilDateBalance = bankAccount.UntilDateBalance(begDate);
     untilDateBedehkar = bankAccount.UntilDateBedehkar(begDate);
     daysBalance = bankAccount.getActivities(begDate, endDate);
 }
    public void Closed_account_throws_exception_when_checking_balance()
    {
        var account = new BankAccount();
        account.Open();
        account.Close();

        Assert.Throws<InvalidOperationException>(() => account.GetBalance());
    }
        public void DepositTest()
        {
            IBankAccount newAccount = new BankAccount(false);

            newAccount.Deposit(200);

            Assert.AreEqual(newAccount.GetBalance(), 200);
        }
Exemple #25
0
 private static void Display(BankAccount aBankAccount, BankAccount bBankAccount)
 {
     Console.WriteLine("The first bank account has these values:");
     Console.WriteLine(aBankAccount.OwnerFullName + "  " + aBankAccount.Balance);
     Console.WriteLine();
     Console.WriteLine("The second bank account has these values:");
     Console.WriteLine(bBankAccount.OwnerFullName + "  " + bBankAccount.Balance);
 }
        public void Given_a_clean_bank_account_when_credited_with_100_then_balance_is_100()
        {
            var model = new BankAccount();
            var handler = new ConventionEventHandler(model);

            handler.OnNext(new Credited(100));

            Assert.That(model.Balance == 100);
        }
 public void TestCreate()
 {
     BankAccount ba = new BankAccount();
     ba.name = "Homer Jay";
     ba.account_number = "112233a";
     ba.routing_number = "121042882";
     ba.type = BankAccount.checking;
     ba.Save();
 }
 public void TestCreate()
 {
     var ba = new BankAccount();
     ba.Name = "Homer Jay";
     ba.AccountNumber = "112233a";
     ba.RoutingNumber = "121042882";
     ba.Type = BankAccount.Checking;
     ba.Save();
 }
        public void TestWithdrawFromAccount_EnoughMoney()
        {
            MockLogging mockLogging = new MockLogging();
            MockBank mockBank = new MockBank("123123", 600);
            BankAccount b = new BankAccount("123123", mockLogging, mockBank);
            b.Withdraw(500);

            Assert.That(mockBank.RequiredSumma, Is.EqualTo(500));
        }
Exemple #30
0
 protected BankAccount createBankAccount()
 {
     BankAccount bankAccount = new BankAccount();
     bankAccount.name = "Johann Bernoulli";
     bankAccount.routing_number = "121000358";
     bankAccount.account_number = "9900000002";
     bankAccount.account_type = "checking";
     bankAccount.Save();
     return bankAccount;
 }
Exemple #31
0
 public Shop(Guid id, string name, string firstName, string lastName, string emailAddress,
             Guid userId, string description, string nationalCode, ShopAddress address, BankAccount bankAccount,
             ImageDocuments imageDocuments, string mobileNumber, int areaRadius, int metrage,
             int defaultDiscount, long marketerId, long personNumber)
     : base(id, firstName, lastName, emailAddress, userId, mobileNumber, personNumber)
 {
     Name            = name;
     ShopStatus      = ShopStatus.Pending;
     Description     = description;
     NationalCode    = nationalCode;
     ShopAddress     = address;
     BankAccount     = bankAccount;
     CreationTime    = DateTime.Now;
     ImageDocuments  = imageDocuments;
     AreaRadius      = areaRadius;
     Metrage         = metrage;
     DefaultDiscount = defaultDiscount;
     MarketerId      = marketerId;
     RecommendCode   = personNumber;
 }
Exemple #32
0
 private void NegativeAlert(BankAccount newAccount)
 {
 }
Exemple #33
0
        public BankAccount RetrieveBankAccountInfo(string loginName)
        {
            BankAccount acct = _lib.GetBankAccountByLoginName(loginName);

            return(acct);
        }
 public void Update(BankAccount acc)
 {
     _context.Entry <BankAccount>(acc).State = EntityState.Modified;
 }
        private void validateBankAccounts(Notification notification, BankAccount originAccount, BankAccount destinationAccount)
        {
            if (originAccount == null || destinationAccount == null)
            {
                notification.addError("Cannot perform the transfer. Invalid data in bank accounts specifications");
                return;
            }

            if (originAccount.Number.Equals(destinationAccount.Number))
            {
                notification.addError("Cannot transfer money to the same bank account");
            }
        }
 public void CheckBalance(BankAccount bankAccount)
 {
     Utility.PrintMessage($"Your bank account balance amount is: {Utility.FormatAmount(bankAccount.Balance)}", true);
 }
Exemple #37
0
        private void linkBankAccount_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            BankAccount ba = new BankAccount();

            ba.ShowDialog();
        }
 public BankAccountFixture()
     : base()
 {
     _account = new BankAccount("87585", 0.0f);
 }
 public void InsertTransaction(BankAccount bankAccount, Transaction transaction)
 {
     _listOfTransactions.Add(transaction);
 }
 public void Create(BankAccount bankAccount)
 {
     _context.BankAccounts.Add(bankAccount);
 }
            public void SortCode_Must_Be_Six_Digits()
            {
                var account = new BankAccount(NUMBER, SORTCODE, NAME);

                Assert.Equal(SORTCODE, account.SortCode);
            }
            public void Number_Must_Be_Six_To_Eight_Digits(string number)
            {
                var account = new BankAccount(number, SORTCODE, NAME);

                Assert.Equal(number, account.Number);
            }
 private void InitTest()
 {
     _bankAccount = CreateEntity();
 }
Exemple #44
0
 public void Show(BankAccount bankAccount)
 {
     WriteLine("{0} earned {1:C} interest.",
               arg0: bankAccount.AccountName,
               arg1: bankAccount.Balance * BankAccount.InterestRate);
 }
        public async Task Handle(RefundMoney refundMoney, IMessageHandlerContext context)
        {
            try
            {
                log.Info($"RefundMoneyHandler, BankAccountId = {refundMoney.BankAccountId}");
                var nHibernateSession = context.SynchronizedStorageSession.Session();
                var bankAccountId     = BankAccountId.FromExisting(refundMoney.BankAccountId);
                var bankAccount       = nHibernateSession.Get <BankAccount>(bankAccountId) ?? BankAccount.NonExisting();
                if (bankAccount.DoesNotExist())
                {
                    var fromBankAccountNotFound = new FromBankAccountNotFound(refundMoney.BankAccountId);
                    await context.Publish(fromBankAccountNotFound);

                    return;
                }
                bankAccount.Refund(refundMoney.Amount);
                nHibernateSession.Save(bankAccount);
                var moneyRefunded = new MoneyRefunded
                                    (
                    bankAccount.BankAccountId.Id,
                    refundMoney.Amount
                                    );
                await context.Publish(moneyRefunded);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " ** " + ex.StackTrace);
            }
        }
Exemple #46
0
 public AccountInterest(BankAccount account)
 {
     Account = account;
 }
        public void CheckCardNoPassword()
        {
            bool pass = false;

            while (!pass)
            {
                inputAccount = new BankAccount();

                Console.WriteLine("\nNote: Actual ATM system will accept user's ATM card to validate");
                Console.Write("and read card number, bank account number and bank account status. \n\n");
                //Console.Write("Enter ATM Card Number: ");
                //inputAccount.CardNumber = Convert.ToInt32(Console.ReadLine());
                inputAccount.CardNumber = Utility.GetValidIntInputAmt("ATM Card Number");

                Console.Write("Enter 6 Digit PIN: ");
                inputAccount.PinCode = Convert.ToInt32(Utility.GetHiddenConsoleInput());
                // for brevity, length 6 is not validated and data type.


                System.Console.Write("\nChecking card number and password.");
                Utility.printDotAnimation();

                foreach (BankAccount account in _accountList)
                {
                    if (inputAccount.CardNumber.Equals(account.CardNumber))
                    {
                        selectedAccount = account;

                        if (inputAccount.PinCode.Equals(account.PinCode))
                        {
                            if (selectedAccount.isLocked)
                            {
                                LockAccount();
                            }
                            else
                            {
                                pass = true;
                            }
                        }
                        else
                        {
                            pass = false;
                            tries++;

                            if (tries >= maxTries)
                            {
                                selectedAccount.isLocked = true;

                                LockAccount();
                            }
                        }
                    }
                }

                if (!pass)
                {
                    Utility.PrintMessage("Invalid Card number or PIN.", false);
                }

                Console.Clear();
            }
        }
Exemple #48
0
        public decimal calculate(BankAccount Account)
        {
            bool escolhido = new Random().Next(100) > 50;

            return((decimal)(escolhido ? 0.25 : 0.15) * Account.Balance);
        }
Exemple #49
0
        static void Main(string[] args)
        {
            /*
             * As we have seen in the previous modules, built-in data types are used to store a single value in a declared variable.
             * For example, int x stores an integer value in a variable named x.
             * In object-oriented programming, a class is a data type that defines a set of variables and methods for a declared object.
             * For example, if you were to create a program that manages bank accounts,
             * a BankAccount class could be used to declare an object that would have all the properties and methods needed for managing an individual bank account, such as a balance variable and Deposit and Withdrawal methods.
             *
             * A class is like a blueprint.
             * It defines the data and behavior for a type.
             * A class definition starts with the keyword class followed by the class name.
             * The class body contains the data and actions enclosed by curly braces.
             */


            /*
             * Just as a built-in data type is used to declare multiple variables, a class can be used to declare multiple objects.
             * As an analogy, in preparation for a new building, the architect designs a blueprint, which is used as a basis for actually building the structure.
             * That same blueprint can be used to create multiple buildings.
             * Programming works in the same fashion. We define (design) a class that is the blueprint for creating objects.
             * In programming, the term type is used to refer to a class name: We're creating an object of a particular type.
             *
             * Once we've written the class, we can create objects based on that class. Creating an object is called instantiation.
             *
             * Each object has its own characteristics.
             * Just as a person is distinguished by name, age, and gender, an object has its own set of values that differentiate it from another object of the same type.
             * The characteristics of an object are called properties.
             * Values of these properties describe the current state of an object.
             * For example, a Person (an object of the class Person) can be 30 years old, male, and named Antonio.
             *
             * Objects aren't always representative of just physical characteristics.
             * For example, a programming object can represent a date, a time, and a bank account.
             * A bank account is not tangible; you can't see it or touch it, but it's still a well-defined object because it has its own properties.
             */


            /*
             * C# has two ways of storing data: by reference and by value.
             * The built-in data types, such as int and double, are used to declare variables that are value types.
             * Their value is stored in memory in a location called the stack.
             *
             * Reference types are used for storing objects. For example, when you create an object of a class, it is stored as a reference type.
             * Reference types are stored in a part of the memory called the heap.
             * When you instantiate an object, the data for that object is stored on the heap, while its heap memory address is stored on the stack.
             * That is why it is called a reference type - it contains a reference (the memory address) to the actual object on the heap.
             */



            /*
             * Stack is used for static memory allocation, which includes all your value types, like x.
             * Heap is used for dynamic memory allocation, which includes custom objects, that might need additional memory during the runtime of your program.
             */


            /*
             *
             * class Person
             *  {
             *    int age;
             *    string name;
             *    public void SayHi()
             *    {
             *      Console.WriteLine("Hi");
             *    }
             *  }
             *
             *  The code above declares a class named Person, which has age and name fields as well as a SayHi method that displays a greeting to the screen.
             *  You can include an access modifier for fields and methods (also called members) of a class. Access modifiers are keywords used to specify the accessibility of a member.
             *  A member that has been defined public can be accessed from outside the class, as long as it's anywhere within the scope of the class object. That is why our SayHi method is declared public, as we are going to call it from outside of the class.
             *
             *
             *  You can also designate class members as private or protected
             *  If no access modifier is defined, the member is private by default.
             */


            /*
             * Now that we have our Person class defined, we can instantiate an object of that type in Main.
             * The new operator instantiates an object and returns a reference to its location:
             *
             *      class Person {
             *       int age;
             *       string name;
             *
             *      public void SayHi() {
             *       Console.WriteLine("Hi");
             *      }
             *     }
             *
             *
             *      static void Main(string[] args)
             *      {
             *          Person p1 = new Person();
             *          p1.SayHi();
             *      }
             */

            // Instantiate Car type object and call horn()
            Car c = new Car();

            c.horn();


            /*
             *
             * You can access all public members of a class using the dot operator.
             * Besides calling a method, you can use the dot operator to make an assignment when valid.
             *
             *       class Dog
             *      {
             *          public string name;
             *          public int age;
             *      }
             *      static void Main(string[] args)
             *      {
             *          Dog bob = new Dog();
             *          bob.name = "Bobby";
             *          bob.age = 3;
             *
             *          Console.WriteLine(bob.age);
             *      }
             */



            /*
             * Part of the meaning of the word encapsulation is the idea of "surrounding" an entity, not just to keep what's inside together, but also to protect it.
             * In programming, encapsulation means more than simply combining members together within a class; it also means restricting access to the inner workings of that class.
             * Encapsulation is implemented by using access modifiers. An access modifier defines the scope and visibility of a class member.
             *
             * Encapsulation is also called information hiding.
             */

            /*
             * C# supports the following access modifiers: public, private, protected, internal, protected internal.
             * As seen in the previous examples, the public access modifier makes the member accessible from the outside of the class.
             * The private access modifier makes members accessible only from within the class and hides them from the outside.
             *
             */


            /*
             * We used encapsulation to hide the balance member from the outside code. Then we provided restricted access to it using public methods. The class data can be read through the GetBalance method and modified only through the Deposit and Withdraw methods.
             * You cannot directly change the balance variable. You can only view its value using the public method. This helps maintain data integrity.
             * We could add different verification and checking mechanisms to the methods to provide additional security and prevent errors.
             */

            BankAccount b = new BankAccount();

            b.Deposit(199);
            b.Withdraw(42);
            Console.WriteLine(b.GetBalance());

            /*
             * A class constructor is a special member method of a class that is executed whenever a new object of that class is created.
             * A constructor has exactly the same name as its class, is public, and does not have any return type
             *
             *  class Person
             *  {
             *    private int age;
             *    public Person()
             *    {
             *      Console.WriteLine("Hi there");
             *    }
             *  }
             *
             *
             *  This can be useful in a number of situations.
             *  For example, when creating an object of type BankAccount, you could send an email notification to the owner.
             *  The same functionality could be achieved using a separate public method.
             *  The advantage of the constructor is that it is called automatically.
             *
             *
             *  Constructors can be very useful for setting initial values for certain member variables.
             *  A default constructor has no parameters.
             *  However, when needed, parameters can be added to a constructor.
             *
             *  Constructors can be overloaded like any method by using different numbers of parameters.
             */

            Person p = new Person("David");

            Console.WriteLine(p.getName());



            /*
             * As we have seen in the previous lessons, it is a good practice to encapsulate members of a class and provide access to them only through public methods.
             * A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field.
             * Properties can be used as if they are public data members, but they actually include special methods called accessors.
             * The accessor of a property contains the executable statements that help in getting (reading or computing) or setting (writing) a corresponding field.
             * Accessor declarations can include a get accessor, a set accessor, or both.
             *
             *      class Person
             *          {
             *            private string name; //field
             *
             *            public string Name //property
             *            {
             *              get { return name; }
             *              set { name = value; }
             *            }
             *          }
             *
             *
             *  The Person class has a Name property that has both the set and the get accessors.
             *  The set accessor is used to assign a value to the name variable; get is used to return its value.
             *
             *  value is a special keyword, which represents the value we assign to a property using the set accessor.
             *  The name of the property can be anything you want, but coding conventions dictate properties have the same name as the private field with a capital letter.
             *
             *
             *          class Person
             *          {
             *              private string name;
             *              public string Name
             *              {
             *                  get { return name; }
             *                  set { name = value; }
             *              }
             *          }
             *          static void Main(string[] args)
             *          {
             *              Person p = new Person();
             *              p.Name = "Bob";
             *              Console.WriteLine(p.Name);
             *          }
             */

            /*
             * Any accessor of a property can be omitted.
             *
             *  class Person
             *  {
             *    private string name;
             *    public string Name
             *    {
             *      get { return name; }
             *    }
             *  }
             *
             */



            /*
             * So, why use properties? Why not just declare the member variable public and access it directly?
             * With properties you have the option to control the logic of accessing the variable.
             * For example, you can check if the value of age is greater than 0, before assigning it to the variable:
             *
             *  class Person
             *  {
             *    private int age=0;
             *    public int Age
             *    {
             *      get { return age; }
             *      set {
             *        if (value > 0)
             *          age = value;
             *      }
             *    }
             *  }
             *
             *  You can have any custom logic with get and set accessors.
             *
             */


            /*
             * When you do not need any custom logic, C# provides a fast and effective mechanism for declaring private members through their properties.
             * For example, to create a private member that can only be accessed through the Name property's get and set accessors, use the following syntax:
             *
             *  public string Name { get; set; }
             *
             *  As you can see, you do not need to declare the private field name separately - it is created by the property automatically. Name is called an auto-implemented property. Also called auto-properties, they allow for easy and short declaration of private members.
             *  We can rewrite the code from our previous example using an auto-property:
             *
             *          class Person
             *          {
             *              public string Name { get; set; }
             *          }
             *          static void Main(string[] args)
             *          {
             *              Person p = new Person();
             *              p.Name = "Bob";
             *              Console.WriteLine(p.Name);
             *          }
             *
             *
             */
        }
Exemple #50
0
        static void Main(string[] args)
        {
            //var bob =new Person();
            //WriteLine(bob.ToString());
            var bob = new Person();

            bob.Name        = "Bob Smith";
            bob.DateOfBirth = new DateTime(1965, 12, 22);
            //dddd means the name of the day of the week
            //d means the ne number of the day of the month
            //MMMM means the name of the month
            //yyyy means the full number of the year
            WriteLine(format: "{0} was born on {1:dddd, d MMMM yyyy}", arg0: bob.Name, arg1: bob.DateOfBirth);

            // another way to initialize the object
            var alice = new Person
            {
                Name        = "Alice Jones",
                DateOfBirth = new DateTime(1998, 3, 7)
            };

            WriteLine(format: "{0} was born on {1:dd MMM yy}", arg0: alice.Name, arg1: alice.DateOfBirth);

            // Use an enum
            // enum internally is stored as int for effiency
            bob.FavoriteAncientWonder = WondersOfTheAncientWorld.StatueOfZeusAtOlimpia;
            WriteLine(format: "{0}'s favorite wonder is {1}. It's integer is {2}", arg0: bob.Name, arg1: bob.FavoriteAncientWonder, arg2: (int)bob.FavoriteAncientWonder);
            bob.BucketList = WondersOfTheAncientWorld.HangingGardensOfBabylon | WondersOfTheAncientWorld.MausoleumAtHalicarnassus;
            //bob.BucketList = (WondersOfTheAncientWorld)18;
            WriteLine($"{bob.Name}'s bucket list is {bob.BucketList}");

            bob.Children.Add(new Person {
                Name = "Alfred"
            });
            bob.Children.Add(new Person {
                Name = "Zoe"
            });
            WriteLine($"{bob.Name} has {bob.Children.Count} children");
            for (int child = 0; child < bob.Children.Count; child++)
            {
                WriteLine($"    {bob.Children[child].Name}");
            }

            // Bank Account Example
            BankAccount.InterestRate = 0.012M; // store a shared value
            var jonesAccount = new BankAccount();

            jonesAccount.AccountName = "Mrs. Jones";
            jonesAccount.Balance     = 2400;
            WriteLine(format: "{0} earned {1:C} interest.", arg0: jonesAccount.AccountName, arg1: jonesAccount.Balance * BankAccount.InterestRate);

            var gerrierAccount = new BankAccount();

            gerrierAccount.AccountName = "Ms. Gerrier";
            gerrierAccount.Balance     = 98;
            WriteLine(format: "{0} earned {1:C} interest.", arg0: gerrierAccount.AccountName, arg1: gerrierAccount.Balance * BankAccount.InterestRate);

            //Using const value
            WriteLine($"{bob.Name} is a {Person.Species}");
            WriteLine($"{bob.Name} was born on {bob.HomePlanet}");

            // Constructor initialization
            var blankPerson = new Person();

            WriteLine(format: "{0} of {1} was created at {2:hh:mm:ss} on a {2:dddd}.", arg0: blankPerson.Name, arg1: blankPerson.HomePlanet, arg2: blankPerson.Instantiated);
            // Second constructor to initialize values
            var gunny = new Person("Gunny", "Mars");

            WriteLine(format: "{0} of {1} was created at {2:hh:mm:ss} on a {2:dddd}.", arg0: gunny.Name, arg1: gunny.HomePlanet, arg2: gunny.Instantiated);

            // calling methods
            bob.WriteToConsole();
            WriteLine(bob.GetOrigin());

            // Get Tuple's fields
            (string, int)fruit = bob.GetFruit();
            WriteLine($"{fruit.Item1}, {fruit.Item2} there are.");

            // Named Tuple
            var fruitNamed = bob.GetNamedFruit();

            WriteLine($"There are {fruitNamed.Number} {fruitNamed.Name}.");

            // Examples of tuples
            var thing1 = ("Neville", 4);

            WriteLine($"{thing1.Item1} has {thing1.Item2}");
            var thing2 = (bob.Name, bob.Children.Count);

            WriteLine($"{thing2.Name} has {thing2.Count}");

            // Deconstructing tuples
            (string fruitName, int fruitNumber) = bob.GetFruit();
            WriteLine($"Deconstructed: {fruitName}, {fruitNumber}");

            // Method paramters
            WriteLine(bob.SayHello());
            WriteLine(bob.SayHello("Emily"));

            // Optional parameters
            WriteLine(bob.OptionalParameters());
            WriteLine(bob.OptionalParameters("Jump!", 98.5));

            // Named paaramters
            WriteLine(bob.OptionalParameters(number: 52.7, command: "Hide!"));

            // You can even use named parameters to skip over optional parameters
            WriteLine(bob.OptionalParameters("Poke!", active: false));

            // in - ref - out parameters
            int a = 10;
            int b = 20;
            int c = 30;

            WriteLine($"Before: a = {a}, b = {b}, c = {c}");
            bob.PassingParameters(a, ref b, out c);
            WriteLine($"After: a = {a}, b = {b}, c = {c}");

            // More example about out parameters
            int d = 10;
            int e = 20;

            WriteLine($"Before: d = {d}, e = {e}, f doesn't exist yet");
            // Simplified C# 7.0 syntax for the out parameter
            bob.PassingParameters(d, ref e, out int f);
            WriteLine($"After: d = {d}, e = {e}, f = {f}");

            // Working with Properties
            var sam = new Person
            {
                Name        = "Sam",
                DateOfBirth = new DateTime(1972, 1, 27)
            };

            WriteLine(sam.Origin);
            WriteLine(sam.Greeting);
            WriteLine(sam.Age);

            sam.FavoriteIceCream = "Chocolate Fudge";
            WriteLine($"Sam's favorite icecream flavor is {sam.FavoriteIceCream}.");
            sam.FavoritePrimaryColor = "blue";
            WriteLine($"Sam's favorite primary color is {sam.FavoritePrimaryColor}.");

            // Indexers
            sam.Children.Add(new Person {
                Name = "Charlie"
            });
            sam.Children.Add(new Person {
                Name = "Ella"
            });
            WriteLine($"Sam's first child is {sam.Children[0].Name}");
            WriteLine($"Sam's second child is {sam.Children[1].Name}");
            // Using Indexers
            WriteLine($"Sam's first child is {sam[0].Name}");
            WriteLine($"Sam's second child is {sam[1].Name}");
        }
 public void Add(BankAccount account)
 {
     account.AddedDate = DateTime.Now;
     this.context.BankAccounts.Add(account);
     this.LastAddedObject = account;
 }
        public async Task <PaymentResult> UseBank(User user, decimal amount, DateTime date, BankAccount userAccount, BankAccount platformAccount, string description = "")
        {
            PaymentChannel channel = await DataContext.Store.GetOneAsync <PaymentChannel>(p => p.Type == ChannelType.Bank);

            DepositPaymentRequest request = new DepositPaymentRequest()
            {
                AddedAtUtc            = DateTime.UtcNow,
                TransactionDate       = date,
                User                  = user,
                Amount                = amount,
                PaymentChannel        = channel,
                Status                = RequestStatus.Pending,
                Description           = description,
                TransactionType       = TransactionType.Deposit,
                UserBankAccountId     = userAccount != null ? userAccount.Id : Guid.Empty,
                PlatformBankAccountId = platformAccount.Id
            };

            await user.AddPaymentRequestAsync(request);

            return(new PaymentResult()
            {
                Status = PaymentStatus.Pending
            });
        }
Exemple #53
0
        public async Task <IActionResult> Create(CreateTransactionViewModel transactionModel)
        {
            var SourceAccount = service_.GetBankAccountByNumber(transactionModel.SourceAccountNumber);

            ViewData["SourceAccountId"]     = SourceAccount.Id;
            ViewData["SourceAccountNumber"] = transactionModel.SourceAccountNumber;
            if (ModelState.IsValid)
            {
                if (SourceAccount != null &&
                    SourceAccount.Balance < transactionModel.Amount &&
                    transactionModel.TransactionType != TransactionTypeEnum.Deposit)
                {
                    ModelState.AddModelError("", "Transaction amount cannot be bigger the balance!");
                    return(View(transactionModel));
                }

                Int64 oldBalance = SourceAccount.Balance;
                Int64 newBalance;
                if (transactionModel.TransactionType == TransactionTypeEnum.Deposit)
                {
                    newBalance             = SourceAccount.Balance + transactionModel.Amount;
                    SourceAccount.Balance += transactionModel.Amount;
                }
                else
                {
                    newBalance             = SourceAccount.Balance - transactionModel.Amount;
                    SourceAccount.Balance -= transactionModel.Amount;
                }
                service_.UpdateBankAccount(SourceAccount);

                Transaction tranasaction = new Transaction
                {
                    TransactionType            = transactionModel.TransactionType,
                    SourceAccountNumber        = transactionModel.SourceAccountNumber,
                    DestinationAccountNumber   = transactionModel.DestinationAccountNumber,
                    DestinationAccountUserName = transactionModel.DestinationAccountUserName,
                    Amount          = transactionModel.Amount,
                    OldBalance      = oldBalance,
                    NewBalance      = newBalance,
                    TransactionTime = DateTime.Now.Date,
                    BankAccountId   = SourceAccount.Id
                };

                Transaction transferTranasaction = null;
                bool        transferResult       = false;
                if (transactionModel.TransactionType == TransactionTypeEnum.Transfer)
                {
                    BankAccount destAccount = service_.GetBankAccountByNumber(transactionModel.DestinationAccountNumber);
                    if (destAccount != null)
                    {
                        if (destAccount.User.UserName == transactionModel.DestinationAccountUserName)
                        {
                            Int64 destOldBalance = destAccount.Balance;
                            Int64 destNewBalance = destAccount.Balance + transactionModel.Amount;
                            service_.UpdateBankAccount(destAccount);
                            transferTranasaction = new Transaction
                            {
                                TransactionType            = TransactionTypeEnum.Deposit,
                                SourceAccountNumber        = transactionModel.SourceAccountNumber,
                                DestinationAccountNumber   = transactionModel.DestinationAccountNumber,
                                DestinationAccountUserName = destAccount.User.UserName,
                                Amount          = transactionModel.Amount,
                                OldBalance      = destOldBalance,
                                NewBalance      = destNewBalance,
                                TransactionTime = DateTime.Now.Date,
                                BankAccountId   = destAccount.Id
                            };

                            transferResult = service_.CreateTransaction(transferTranasaction);
                            if (!transferResult)
                            {
                                ModelState.AddModelError("", "Could not create transfer between bankaccounts!");
                                return(View(transactionModel));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Username not match with the bankaccount!");
                            return(View(transactionModel));
                        }
                    }
                    service_.TransferBetweenAccounts(
                        transactionModel.SourceAccountNumber,
                        transactionModel.DestinationAccountNumber,
                        transactionModel.Amount);
                }


                bool result = service_.CreateTransaction(tranasaction);

                if (result)
                {
                    HttpContext.Session.SetString("UserIsAuthorized", "false");
                    return(RedirectToAction("Details",
                                            new RouteValueDictionary(
                                                new { Controller = "BankAccounts", Action = "Details", Id = SourceAccount.Id })));
                }
                else
                {
                    if (transferResult && transferTranasaction != null)
                    {
                        service_.DeleteTransaction(transferTranasaction.Id);
                    }
                    ModelState.AddModelError("", "Could not create transfer!");
                    return(View(transactionModel));
                }
            }
            return(View(transactionModel));
        }
Exemple #54
0
        static void Main(string[] args)
        {
            var bob = new Person();

            bob.Name        = "Bob Smith";
            bob.DateOfBirth = new DateTime(1965, 12, 22);
            WriteLine(
                format: "{0} was born on {1:dddd, d MMMM yyyy}",
                arg0: bob.Name,
                arg1: bob.DateOfBirth);
            var alice = new Person
            {
                Name        = "Alice Jones",
                DateOfBirth = new DateTime(1998, 3, 7)
            };

            WriteLine(
                format: "{0} was born on {1:dd MMM yy}",
                arg0: alice.Name,
                arg1: alice.DateOfBirth);

            bob.FavoriteAncientWonder =
                WondersOfTheAncientWorld.StatueOfZeusAtOlympia;
            WriteLine(format:
                      "{0}'s favorite wonder is {1}. It's integer is {2}.",
                      arg0: bob.Name,
                      arg1: bob.FavoriteAncientWonder,
                      arg2: (int)bob.FavoriteAncientWonder);

            bob.BucketList =
                WondersOfTheAncientWorld.HangingGardensOfBabylon
                | WondersOfTheAncientWorld.MausoleumAtHalicarnassus;
            // bob.BucketList = (WondersOfTheAncientWorld)18;
            WriteLine($"{bob.Name}'s bucket list is {bob.BucketList}");

            bob.Children.Add(new Person {
                Name = "Alfred"
            });
            bob.Children.Add(new Person {
                Name = "Zoe"
            });

            WriteLine(
                $"{bob.Name} has {bob.Children.Count} children:");
            for (int child = 0; child < bob.Children.Count; child++)
            {
                WriteLine($"  {bob.Children[child].Name}");
            }

            bob.Children.Add(new Person {
                Name = "Alfred"
            });
            bob.Children.Add(new Person {
                Name = "Zoe"
            });

            WriteLine(
                $"{bob.Name} has {bob.Children.Count} children:");
            for (int child = 0; child < bob.Children.Count; child++)
            {
                WriteLine($"  {bob.Children[child].Name}");
            }

            BankAccount.InterestRate = 0.012M; // store a shared value
            var jonesAccount = new BankAccount();

            jonesAccount.AccountName = "Mrs. Jones";
            jonesAccount.Balance     = 2400;
            WriteLine(format: "{0} earned {1:C} interest.",
                      arg0: jonesAccount.AccountName,
                      arg1: jonesAccount.Balance * BankAccount.InterestRate);
            var gerrierAccount = new BankAccount();

            gerrierAccount.AccountName = "Ms. Gerrier";
            gerrierAccount.Balance     = 98;
            WriteLine(format: "{0} earned {1:C} interest.",
                      arg0: gerrierAccount.AccountName,
                      arg1: gerrierAccount.Balance * BankAccount.InterestRate);

            WriteLine($"{bob.Name} is a {Person.Species}");

            WriteLine($"{bob.Name} was born on {bob.HomePlanet}");

            var blankPerson = new Person();

            WriteLine(format:
                      "{0} of {1} was created at {2:hh:mm:ss} on a {2:dddd}.",
                      arg0: blankPerson.Name,
                      arg1: blankPerson.HomePlanet,
                      arg2: blankPerson.Instantiated);

            var gunny = new Person("Gunny", "Mars");

            WriteLine(format:
                      "{0} of {1} was created at {2:hh:mm:ss} on a {2:dddd}.",
                      arg0: gunny.Name,
                      arg1: gunny.HomePlanet,
                      arg2: gunny.Instantiated);

            bob.WriteToConsole();
            WriteLine(bob.GetOrigin());

            (string, int)fruit = bob.GetFruit();
            WriteLine($"{fruit.Item1}, {fruit.Item2} there are.");

            var fruitNamed = bob.GetNamedFruit();

            WriteLine($"There are {fruitNamed.Number} {fruitNamed.Name}.");

            var thing1 = ("Neville", 4);

            WriteLine($"{thing1.Item1} has {thing1.Item2} children.");
            var thing2 = (bob.Name, bob.Children.Count);

            WriteLine($"{thing2.Name} has {thing2.Count} children.");

            (string fruitName, int fruitNumber) = bob.GetFruit();
            WriteLine($"Deconstructed: {fruitName}, {fruitNumber}");

            WriteLine(bob.SayHello());
            WriteLine(bob.SayHelloTo("Emily"));

            WriteLine(bob.OptionalParameters());

            WriteLine(bob.OptionalParameters("Jump!", 98.5));

            WriteLine(bob.OptionalParameters(
                          number: 52.7, command: "Hide!"));

            WriteLine(bob.OptionalParameters("Poke!", active: false));

            int a = 10;
            int b = 20;
            int c = 30;

            WriteLine($"Before: a = {a}, b = {b}, c = {c}");
            bob.PassingParameters(a, ref b, out c);
            WriteLine($"After: a = {a}, b = {b}, c = {c}");

            int d = 10;
            int e = 20;

            WriteLine(
                $"Before: d = {d}, e = {e}, f doesn't exist yet!");
            // simplified C# 7.0 syntax for the out parameter
            bob.PassingParameters(d, ref e, out int f);
            WriteLine($"After: d = {d}, e = {e}, f = {f}");

            var sam = new Person
            {
                Name        = "Sam",
                DateOfBirth = new DateTime(1972, 1, 27)
            };

            WriteLine(sam.Origin);
            WriteLine(sam.Greeting);
            WriteLine(sam.Age);

            sam.FavoriteIceCream = "Chocolate Fudge";
            WriteLine($"Sam's favorite ice-cream flavor is {sam.FavoriteIceCream}.");
            sam.FavoritePrimaryColor = "Red";
            WriteLine($"Sam's favorite primary color is {sam.FavoritePrimaryColor}.");

            sam.Children.Add(new Person {
                Name = "Charlie"
            });
            sam.Children.Add(new Person {
                Name = "Ella"
            });
            WriteLine($"Sam's first child is {sam.Children[0].Name}");
            WriteLine($"Sam's second child is {sam.Children[1].Name}");
            WriteLine($"Sam's first child is {sam[0].Name}");
            WriteLine($"Sam's second child is {sam[1].Name}");
        }
Exemple #55
0
        public BankAccount RetrieveBankAccountInfo(int id)
        {
            BankAccount acct = _lib.GetBankAccountById(id);

            return(acct);
        }
 public Withdraw(BankAccount bankAccount, double amount)
 {
     this.bankAccount = bankAccount; this.amount = amount;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RecurringDetail" /> class.
        /// </summary>
        /// <param name="TokenDetails">TokenDetails.</param>
        /// <param name="SocialSecurityNumber">SocialSecurityNumber.</param>
        /// <param name="FirstPspReference">FirstPspReference.</param>
        /// <param name="CreationDate">CreationDate.</param>
        /// <param name="Acquirer">Acquirer.</param>
        /// <param name="Bank">Bank.</param>
        /// <param name="ShopperName">ShopperName.</param>
        /// <param name="AcquirerAccount">AcquirerAccount.</param>
        /// <param name="AliasType">AliasType.</param>
        /// <param name="Name">An optional descriptive name for this recurring detail.</param>
        /// <param name="Variant">Variant.</param>
        /// <param name="RecurringDetailReference">The reference that uniquely identifies the recurring detail.</param>
        /// <param name="Alias">Alias.</param>
        /// <param name="ContractTypes">ContractTypes.</param>
        /// <param name="PaymentMethodVariant">PaymentMethodVariant.</param>
        /// <param name="BillingAddress">BillingAddress.</param>
        /// <param name="AdditionalData">AdditionalData.</param>
        /// <param name="Card">Card.</param>
        public RecurringDetail(TokenDetails TokenDetails = default(TokenDetails), string SocialSecurityNumber = default(string), string FirstPspReference = default(string), DateTime?CreationDate = default(DateTime?), string Acquirer = default(string), BankAccount Bank = default(BankAccount), Name ShopperName = default(Name), string AcquirerAccount = default(string), string AliasType = default(string), string Name = default(string), string Variant = default(string), string RecurringDetailReference = default(string), string Alias = default(string), List <string> ContractTypes = default(List <string>), string PaymentMethodVariant = default(string), Address BillingAddress = default(Address), Dictionary <string, string> AdditionalData = default(Dictionary <string, string>), Card Card = default(Card))
        {
            this.TokenDetails         = TokenDetails;
            this.SocialSecurityNumber = SocialSecurityNumber;
            this.FirstPspReference    = FirstPspReference;
            this.CreationDate         = CreationDate;
            this.Acquirer             = Acquirer;

            this.Bank                     = Bank;
            this.ShopperName              = ShopperName;
            this.AcquirerAccount          = AcquirerAccount;
            this.AliasType                = AliasType;
            this.Name                     = Name;
            this.Variant                  = Variant;
            this.RecurringDetailReference = RecurringDetailReference;
            this.Alias                    = Alias;
            this.ContractTypes            = ContractTypes;
            this.PaymentMethodVariant     = PaymentMethodVariant;
            this.BillingAddress           = BillingAddress;
            this.AdditionalData           = AdditionalData;
            this.Card                     = Card;
        }
 public Deposit(BankAccount bankAccount, double amount)
 {
     this.bankAccount = bankAccount; this.amount = amount;
 }
Exemple #59
0
        private static bool IsReceiptRequiredByPaymentLevelCriterium(OfflineDepositConfirm deposit, BankAccount bankAccount)
        {
            if (deposit.TransferType == TransferType.DifferentBank)
            {
                switch (deposit.OfflineDepositType)
                {
                case DepositMethod.ATM:
                    return(bankAccount.AtmDifferentBank);

                case DepositMethod.CounterDeposit:
                    return(bankAccount.CounterDepositDifferentBank);

                case DepositMethod.InternetBanking:
                    return(bankAccount.InternetDifferentBank);

                default:
                    return(false);
                }
            }

            if (deposit.TransferType == TransferType.SameBank)
            {
                switch (deposit.OfflineDepositType)
                {
                case DepositMethod.ATM:
                    return(bankAccount.AtmSameBank);

                case DepositMethod.CounterDeposit:
                    return(bankAccount.CounterDepositSameBank);

                case DepositMethod.InternetBanking:
                    return(bankAccount.InternetSameBank);

                default:
                    return(false);
                }
            }

            return(false);
        }
        private static void Seed(BillsPaymentSystemContext db)
        {
            using (db)
            {
                var user = new User()
                {
                    FirstName = "Pesho",
                    LastName  = "Peshov",
                    Email     = "*****@*****.**",
                    Password  = "******"
                };

                var creditCards = new CreditCard[]
                {
                    new CreditCard()
                    {
                        ExpirationDate = DateTime.ParseExact("20.05.2020", "dd.MM.yyyy", null),
                        Limit          = 1000m,
                        MoneyOwed      = 5m
                    },
                    new CreditCard()
                    {
                        ExpirationDate = DateTime.ParseExact("21.05.2020", "dd.MM.yyyy", null),
                        Limit          = 400m,
                        MoneyOwed      = 200m
                    }
                };

                var bankAccount = new BankAccount()
                {
                    Balance   = 1500m,
                    BankName  = "Swiss Bank",
                    SwiftCode = "SWSSBANK"
                };

                var paymentMethods = new PaymentMethod[]
                {
                    new PaymentMethod()
                    {
                        User       = user,
                        CreditCard = creditCards[0],
                        Type       = PaymentMethodType.CreditCard
                    },
                    new PaymentMethod()
                    {
                        User       = user,
                        CreditCard = creditCards[1],
                        Type       = PaymentMethodType.CreditCard
                    },
                    new PaymentMethod()
                    {
                        User        = user,
                        BankAccount = bankAccount,
                        Type        = PaymentMethodType.BankAccount
                    }
                };

                db.Users.Add(user);
                db.CreditCards.AddRange(creditCards);
                db.BankAccounts.Add(bankAccount);
                db.PaymentMethods.AddRange(paymentMethods);

                db.SaveChanges();
            }
        }