internal static void Seed(BillsPaymentSystemContext context, int count) { for (int i = 0; i < count; i++) { var firstName = TextGenerator.FirstName(); var user = new User() { FirstName = firstName, LastName = TextGenerator.LastName(), Email = EmailGenerator.NewEmail(firstName), Password = TextGenerator.Password(12) }; var result = new List <ValidationResult>(); if (AttributeValidator.IsValid(user, result)) { context.Users.Add(user); } else { Console.WriteLine(string.Join(Environment.NewLine, result)); } } context.SaveChanges(); }
internal static void Seed(BillsPaymentSystemContext context, int count, List <User> users) { for (int i = 0; i < count; i++) { var payment = new PaymentMethod() { User = users[IntGenerator.GenerateInt(0, users.Count - 1)], Type = PaymentType.BankAccount, BankAccount = new BankAccount() { BankAccountId = i, //Balance = PriceGenerator.GeneratePrice(), BankName = TextGenerator.FirstName() + "\'s Bank", SwiftCode = TextGenerator.Password(10) }, BankAccountId = i }; payment.BankAccount.Deposit(PriceGenerator.GeneratePrice()); var result = new List <ValidationResult>(); if (AttributeValidator.IsValid(payment, result)) { context.PaymentMethods.Add(payment); } else { Console.WriteLine(string.Join(Environment.NewLine, result)); } payment = new PaymentMethod() { User = users[IntGenerator.GenerateInt(0, users.Count - 1)], Type = PaymentType.CreditCard, CreditCard = new CreditCard() { CreditCardId = i, ExpirationDate = DateGenerator.FutureDate(), Limit = PriceGenerator.GeneratePrice(), //MoneyOwed = PriceGenerator.GeneratePrice() }, CreditCardId = i }; payment.CreditCard.Withdraw(PriceGenerator.GeneratePrice()); result = new List <ValidationResult>(); if (AttributeValidator.IsValid(payment, result)) { context.PaymentMethods.Add(payment); } else { Console.WriteLine(string.Join(Environment.NewLine, result)); } } context.SaveChanges(); }
internal static void InitialStudentSeed(StudentSystemContext context, int count) { for (int i = 0; i < count; i++) { var student = new Student() { Name = TextGenerator.FirstName() + " " + TextGenerator.LastName(), RegisteredOn = DateGenerator.PastDate() }; context.Students.Add(student); } context.SaveChanges(); }
internal static void InitialCourseSeed(StudentSystemContext context, int count) { for (int i = 0; i < count; i++) { var date = DateGenerator.RandomDate(); var course = new Course() { Name = TextGenerator.FirstName(), StartDate = date, EndDate = DateGenerator.DateAfter(date), Price = PriceGenerator.GeneratePrice() }; context.Courses.Add(course); } context.SaveChanges(); }