/* * /// <summary> * /// Creates a random list of teachers and returns the result * /// </summary> * /// <param name="numberOfTeacher">An integer value</param> * /// <returns>An array of teachers</returns> * public static Teacher[] Create(int numberOfTeacher) * { * List<Teacher> result = new List<Teacher>(); * * List<string> listOfField = FileHelper.GetListOfField(); * Random rnd = new Random(); * * for (uint i = 0; i < numberOfTeacher; i++) * { * //id * String uuid = Guid.NewGuid().ToString(); * * //gender * bool gender = rnd.Next(2) == 1; * * //name * string fullName = GenerateDataHelper.GetRandomNameByGender(gender); * * //Field * int index = rnd.Next(listOfField.Count); * string[] fields = listOfField[index].Split(','); * string field = fields[0].Trim(); * * result.Add(new Teacher(uuid, fullName, gender, field)); * } * return result.ToArray(); * }*/ /// <summary> /// Creates a random list of teachers and returns the result /// </summary> /// <returns>An array of teachers</returns> public static Teacher[] Create() { List <Teacher> result = new List <Teacher>(); Field[] listOfField = DataList.FieldList; Random rnd = new Random(); while (true) { //id string uuid = Guid.NewGuid().ToString(); //gender bool gender = rnd.Next(2) == 1; //name string fullName = GenerateDataHelper.GetRandomNameByGender(gender); //field int index = rnd.Next(listOfField.Length); string field = listOfField[index].UUID; Teacher x = new Teacher(uuid, fullName, gender, field); result.Add(x); int num = Attendance.Create(uuid, field); if (num == 0) { result.Remove(x); break; } } return(result.ToArray()); }
/* * /// <summary> * /// Creates a random list of students and returns the result * /// </summary> * /// <param name="numberOfStudent">An integer value</param> * /// <returns>An array of students</returns> * public static Student[] Create(int numberOfStudent) * { * List<Student> result = new List<Student>(); * * Random rnd = new Random(); * * List<string> listOfClasses = FileHelper.GetListOfClass(); * * int currentTotal = 0; * int quantity; * for (int i = 0; i < listOfClasses.Count; i++) * { * if (i == listOfClasses.Count) * { * quantity = numberOfStudent - currentTotal; * } * else * { * quantity = rnd.Next(30, 51); * } * * string[] classs = listOfClasses[i].Split(','); * string classInfo = classs[0].Trim(); * string levelId = classs[1].Trim(); * string level = FileHelper.GetLevelByPrimaryKey(levelId).Split(',')[1]; * * for (int j = 0; j < quantity; j++) * { * //id * string uuid = Guid.NewGuid().ToString(); * * //gender * bool gender = rnd.Next(2) == 1; * * //name * string fullName = GenerateDataHelper.GetRandomNameByGender(gender); * * //birthdate * DateTime birthdate = GenerateDataHelper.GetRandomBirthdayByLevel(level); * * result.Add(new Student(uuid, fullName, birthdate, gender, classInfo)); * currentTotal++; * } * } * return result.ToArray(); * }*/ /// <summary> /// Creates a random list of students and returns the result /// </summary> /// <param name="numberOfStudent">An integer value</param> /// <returns>An array of students</returns> public static Student[] Create(int numberOfStudent) { List <Student> result = new List <Student>(); Random rnd = new Random(); Level[] listOfLevel = DataList.LevelList; int amountEachLevel = (int)Math.Ceiling((double)numberOfStudent / listOfLevel.Length) + 1; int levelIndex = 0; int count = 0; for (int i = 0; i < numberOfStudent; i++) { //id string uuid = Guid.NewGuid().ToString(); //gender bool gender = rnd.Next(2) == 1; //name string fullName = GenerateDataHelper.GetRandomNameByGender(gender); //birthdate string level = listOfLevel[levelIndex].Name; DateTime birthdate = GenerateDataHelper.GetRandomBirthdayByLevel(level); result.Add(new Student(uuid, fullName, birthdate, gender, listOfLevel[levelIndex].UUID)); if (count == amountEachLevel) { levelIndex++; amountEachLevel--; count = 0; } } return(result.ToArray()); }