public static StudentModel CreateModelFromEntity(Student st) { return new StudentModel() { StudentId = st.StudentId, FirstName = st.FirstName, LastName = st.LastName, Age = st.Age, Grade = st.Grade, }; }
private IEnumerable<Student> GenerateRandomStudents(int count) { List<Student> students = new List<Student>(); for (int i = 1; i <= count; i++) { Student student = new Student() { StudentId = i, Name = "Name#" + i, }; int marksCount = random.Next(0, 10); student.Marks = GenerateMarks(marksCount); students.Add(student); } return students; }
private List<Student> GenerateStudents(int num) { List<Student> students = new List<Student>(); Random rand = new Random(); for (int i = 0; i < num; i++) { Student currStudent = new Student(); currStudent.Id = i + 1; currStudent.Grade = rand.Next(1, 13); currStudent.Name = "Student#" + i; for (int k = 0; k < i; k++) { Mark currMark = new Mark(); currMark.Subject = "Subject#" + k; currMark.Score = rand.Next(2, 7); currStudent.Marks.Add(currMark); } students.Add(currStudent); } return students; }