private static void AddLogins(NWBAContext context) { const string format = "dd/MM/yyyy hh:mm:ss tt"; context.Login.AddRange( new Login { UserID = "12345678", CustomerID = 2100, PasswordHash = "YBNbEL4Lk8yMEWxiKkGBeoILHTU7WZ9n8jJSy8TNx0DAzNEFVsIVNRktiQV+I8d2", Status = "Active", LoginAttempts = 0, ModifyDate = DateTime.ParseExact("19/12/2019 08:00:00 PM", format, null) }, new Login { UserID = "38074569", CustomerID = 2200, PasswordHash = "EehwB3qMkWImf/fQPlhcka6pBMZBLlPWyiDW6NLkAh4ZFu2KNDQKONxElNsg7V04", Status = "Active", LoginAttempts = 0, ModifyDate = DateTime.ParseExact("19/12/2019 09:00:00 PM", format, null) }, new Login { UserID = "17963428", CustomerID = 2300, PasswordHash = "LuiVJWbY4A3y1SilhMU5P00K54cGEvClx5Y+xWHq7VpyIUe5fe7m+WeI0iwid7GE", Status = "Active", LoginAttempts = 0, ModifyDate = DateTime.ParseExact("19/12/2019 10:00:00 PM", format, null) });; context.SaveChanges(); }
private static void AddAccounts(NWBAContext context) { const string format = "dd/MM/yyyy hh:mm:ss tt"; context.Account.AddRange( new Account { AccountNumber = 4100, AccountType = "S", CustomerID = 2100, Balance = 100, ModifyDate = DateTime.ParseExact("19/12/2019 08:00:00 PM", format, null) }, new Account { AccountNumber = 4101, AccountType = "C", CustomerID = 2100, Balance = 500, ModifyDate = DateTime.ParseExact("19/12/2019 08:30:00 PM", format, null) }, new Account { AccountNumber = 4200, AccountType = "S", CustomerID = 2200, Balance = 500.95m, ModifyDate = DateTime.ParseExact("19/12/2019 09:00:00 PM", format, null) }, new Account { AccountNumber = 4300, AccountType = "C", CustomerID = 2300, Balance = 1250.50m, ModifyDate = DateTime.ParseExact("19/12/2019 10:00:00 PM", format, null) }); context.Database.OpenConnection(); try { context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Account ON"); context.SaveChanges(); context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Account OFF"); } finally { context.Database.CloseConnection(); } }
public static void Initialize(IServiceProvider serviceProvider) { using var context = new NWBAContext(serviceProvider.GetRequiredService <DbContextOptions <NWBAContext> >()); //Look for customers. if (context.Customer.Any()) { return; // DB has already been seeded. } AddCustomers(context); AddLogins(context); AddAccounts(context); AddTransactions(context); }
private static void AddCustomers(NWBAContext context) { context.Customer.AddRange( new Customer { CustomerID = 2100, CustomerName = "Matthew Bolger", Address = "123 Fake Street", City = "Melbourne", PostCode = "3000", TFN = "1337", State = "VIC", Phone = "(61)-94491023" }, new Customer { CustomerID = 2200, CustomerName = "Rodney Cocker", Address = "456 Real Road", City = "Melbourne", PostCode = "3005", TFN = "43770", State = "VIC", Phone = "(61)-93906170" }, new Customer { CustomerID = 2300, CustomerName = "Shekhar Kalra", Phone = "(61)-93906170" }); context.Database.OpenConnection(); try { context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Customer ON"); context.SaveChanges(); context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Customer OFF"); } finally { context.Database.CloseConnection(); } }
private static void AddTransactions(NWBAContext context) { const string format = "dd/MM/yyyy hh:mm:ss tt"; const string openingBalance = "Opening balance"; context.Transaction.AddRange( new Transaction { TransactionType = "D", AccountNumber = 4100, Amount = 100, Comment = openingBalance, ModifyDate = DateTime.ParseExact("19/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4101, Amount = 500, Comment = openingBalance, ModifyDate = DateTime.ParseExact("19/12/2019 08:30:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4200, Amount = 500.95m, Comment = openingBalance, ModifyDate = DateTime.ParseExact("19/12/2019 09:00:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4300, Amount = 1250.50m, Comment = "Opening balance", ModifyDate = DateTime.ParseExact("19/12/2019 10:00:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4100, Amount = 200, ModifyDate = DateTime.ParseExact("21/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("22/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("22/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 100, ModifyDate = DateTime.ParseExact("24/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4100, Amount = 200, ModifyDate = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "T", AccountNumber = 4100, DestinationAccountNumber = 4200, Amount = 100, Comment = "Owe Rodney Pizza Money", ModifyDate = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 25, ModifyDate = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null) }, new Transaction { TransactionType = "D", AccountNumber = 4100, Amount = 300, ModifyDate = DateTime.ParseExact("01/01/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("04/01/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 75, ModifyDate = DateTime.ParseExact("11/01/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 25, ModifyDate = DateTime.ParseExact("22/01/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("28/01/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("02/02/2020 08:00:00 AM", format, null) }, new Transaction { TransactionType = "W", AccountNumber = 4100, Amount = 50, ModifyDate = DateTime.ParseExact("05/02/2020 08:00:00 AM", format, null) }); context.SaveChanges(); }