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(); } }
private static void Seed(BillsPaymentSystemContext context) { var users = new[] { new User { FirstName = "Anton", LastName = "Apostolov", Password = "******", Email = "*****@*****.**" }, new User { FirstName = "Zornitsa", LastName = "Orlova", Password = "******", Email = "*****@*****.**" }, new User { FirstName = "Kaloyan", LastName = "Minchev", Password = "******", Email = "*****@*****.**" } }; var creditCards = new[] { new CreditCard ( 600, 230.18m, new DateTime(2019, 11, 30) ), new CreditCard ( 900, 0, new DateTime(2018, 10, 31) ), new CreditCard ( 3200, 120.35m, new DateTime(2020, 05, 31) ), new CreditCard ( 50000, 0, new DateTime(2029, 01, 31) ) }; var bankAccounts = new[] { new BankAccount ( 301.18m, "First Investment Bank", "FINVBGSFXXX" ), new BankAccount ( 540329.85m, "Banque Cantonale De Geneve", "BCGECHGGXXX" ) }; var paymentMethods = new[] { new PaymentMethod { User = users[0], Type = PaymentMethodType.CreditCard, CreditCard = creditCards[0] }, new PaymentMethod { User = users[0], Type = PaymentMethodType.BankAccount, BankAccount = bankAccounts[0] }, new PaymentMethod { User = users[1], Type = PaymentMethodType.CreditCard, CreditCard = creditCards[1] }, new PaymentMethod { User = users[1], Type = PaymentMethodType.CreditCard, CreditCard = creditCards[2] }, new PaymentMethod { User = users[2], Type = PaymentMethodType.BankAccount, BankAccount = bankAccounts[1] }, new PaymentMethod() { User = users[2], Type = PaymentMethodType.CreditCard, CreditCard = creditCards[3] } }; context.PaymentMethods.AddRange(paymentMethods); context.SaveChanges(); }