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 Homework GenerateHomework(List <Course> courses, List <Student> students) { var homework = new Homework() { Content = TextGenerator.Text("Lab", "Exercise", "Exam", "Other stuff"), SubmissionTime = DateGenerator.RandomDate(), ContentType = (ContentType)IntGenerator.GenerateInt(1, 3), Course = courses[IntGenerator.GenerateInt(0, courses.Count - 1)], Student = students[IntGenerator.GenerateInt(0, students.Count - 1)] }; return(homework); }
private static StudentDto GetStudent() { var name = TextGenerator.FirstName; return(new StudentDto() { Name = name, Gender = "Male", BirthDate = DateGenerator.PastDate.ToString("yyyy'/'MM'/'dd"), PhoneNumber = IntGenerator.GenerateInt(1000000, 9999999), Email = EmailGenerator.NewEmail(name), FacultyNumber = IntGenerator.GenerateInt(1000000, 9999999), Specialty = TextGenerator.Text("C# Web Developer", "Java Web Developer", "JavaScript FrontEnd Developer"), University = "SoftUni", Exams = GetExams(1) }); }