/// <summary> /// Adds a student to the database and student list /// </summary> public void AddStudent() { Dictionary <string, object> info = GetStudentAddValues(); try { foreach (var item in info) { if (!addStudentStrings.Contains(item.Key)) { throw new System.ArgumentException(); } } } catch (System.Exception e) { Debug.LogError("Dictionary not properly initialized, error: " + e.Message); } DBConnector.CreateStudentFunc((successful) => { if (successful) { DBConnector.GetUserData((callback) => { Student.Students.Add(callback[0]); Student student = (Student)callback[0]; PropertyInfo[] properties = student.GetType().GetProperties(); GameObject studentPrefab = Instantiate(StudentListPrefab, StudentPrefabParent.transform); Text[] texts = studentPrefab.GetComponentsInChildren <Text>(); InputField[] inputs = studentPrefab.GetComponentsInChildren <InputField>(); inputs[0].text = properties[(int)StudentProperties.Name].GetValue(student, null).ToString(); inputs[1].text = properties[(int)StudentProperties.Pincode].GetValue(student, null).ToString(); texts[2].text = properties[(int)StudentProperties.Id].GetValue(student, null).ToString(); }, isTeacher: false, studentName: (string)info[addStudentStrings[0]]); panelHandler.CloseAddStudent(); } else { Debug.LogError("Something went wrong, read error above for more info"); } }, (string)info[addStudentStrings[0]], (string)info[addStudentStrings[1]], (int)info[addStudentStrings[2]]); }