private void AddNewStudent() { Console.WriteLine("Enter Id"); int id; string userInput = Console.ReadLine(); if (!Int32.TryParse(userInput, out id)) { Console.WriteLine("Invalid Id,please enter valid positive Integer"); return; } Console.WriteLine("Enter Name"); string name = Console.ReadLine(); Console.WriteLine("Enter Mark1"); int mark1; userInput = Console.ReadLine(); if ((!Int32.TryParse(userInput, out mark1)) || mark1 < 0 || mark1 > 100) { Console.WriteLine("Invalid Mark1,Please Enter Mark1 between mark1<0&&mark1>100"); return; } Console.WriteLine("Enter Mark2"); int mark2; userInput = Console.ReadLine(); if ((!Int32.TryParse(userInput, out mark2)) || mark2 < 0 || mark2 > 100) { Console.WriteLine("Invalid Mark1,Please Enter Mark2 between mark2<0&&mark2>100"); return; } Console.WriteLine("Enter Mark3"); int mark3; userInput = Console.ReadLine(); if ((!Int32.TryParse(userInput, out mark3)) || mark3 < 0 || mark3 > 100) { Console.WriteLine("Invalid Mark1,Please Enter Mark3 between mark3<0&&mark3>100"); return; } Console.WriteLine("Enter SchoolName"); string schoolName = Console.ReadLine(); Console.WriteLine("Enter District"); string district = Console.ReadLine(); Student student = new Student(id, name, mark1, mark2, mark3, schoolName, district); db.AddStudent(student); }
public void AddStudent(Student student) { students.Add(student); }
private void AddTestStudents() { Random random = new Random(); int addedTestStudents = 10; int studentCount = db.Count; for (int i = 1; i <=addedTestStudents; i++) { int studentId=studentCount+i; string name="student"+ random.Next(10).ToString(); int mark1=random.Next(90,100); int mark2=random.Next(80,100); int mark3=random.Next(100); string schoolName="schoolName"+random.Next(10).ToString(); string district="district"+random.Next(10).ToString(); Student student =new Student(id:studentId,name:name,mark1:mark1,mark2:mark2,mark3:mark2,schoolName:schoolName,district:district); db.AddStudent(student); } }