public openCourse AddStudentToOpenCourse(string id, [FromBody] Student Studentx) { var data = DataopenCourse.FirstOrDefault(it => it.IdCourse == id.ToString()); var AA = data.Students.ToList(); Console.WriteLine(data.Students.ToList()); var item = new Student { IdStudent = Studentx.IdStudent, NameStudent = Studentx.NameStudent, Username = Studentx.Username, Password = Studentx.Password }; AA.Add(item); Console.WriteLine(AA.ToList()); var item2 = new openCourse { IdCourse = id.ToString(), NameCourse = data.NameCourse, Teacher = data.Teacher, Students = AA.ToArray(), }; DataopenCourse.Remove(data); // DataopenCourse.Remove(item2); DataopenCourse.Add(item2); return(item2); }
public openCourse AddCourse([FromBody] openCourse openCoursex) { var xxx = openCoursex.Teacher.ToArray(); var yyy = openCoursex.Students.ToArray(); var aa = DataClass.ToList(); var item = new openCourse { IdCourse = openCoursex.IdCourse, NameCourse = openCoursex.NameCourse, Teacher = openCoursex.Teacher, Students = yyy.ToArray() }; DataopenCourse.Add(item); return(item); }
public openCourse AddTeacherToOpenCourse(string id, [FromBody] Teacher Teacherx) { var data = DataopenCourse.FirstOrDefault(it => it.IdCourse == id.ToString()); //var AA = data.Teacher.ToList(); var AA = data.Teacher.ToList(); Console.WriteLine(data.Teacher.ToList()); var BB = data.Students.ToList(); // Console.WriteLine(data.Students.ToList()); var item = new Teacher { IdTeacher = Teacherx.IdTeacher, NameTeacher = Teacherx.NameTeacher, Username = Teacherx.Username, Password = Teacherx.Password }; //AA.Remove(item); AA.Add(item); // Console.WriteLine(AA.ToList()); var item2 = new openCourse { IdCourse = id.ToString(), NameCourse = data.NameCourse, Teacher = AA.ToArray(), Students = BB.ToArray(), }; DataopenCourse.Remove(data); // DataopenCourse.Add(data); DataopenCourse.Add(item2); //DataopenCourse.Add(data); return(item2); }
public openCourse AddScoreToStudent(string id, string ids, [FromBody] Student Studentx) { var data = DataopenCourse.FirstOrDefault(it => it.IdCourse == id.ToString()); var AA = data.Students.ToList(); var data2 = AA.FirstOrDefault(it => it.IdStudent == ids.ToString()); Console.WriteLine(data.Students.ToList()); var item = new Student { IdStudent = ids.ToString(), NameStudent = data2.NameStudent, Username = data2.Username, Password = data2.Password, score = Studentx.score, MidScore = Studentx.MidScore, FinalScore = Studentx.FinalScore, TotalScore = Studentx.TotalScore, Grade = Studentx.Grade }; AA.Remove(data2); AA.Add(item); Console.WriteLine(AA.ToList()); var item2 = new openCourse { IdCourse = id.ToString(), NameCourse = data.NameCourse, Teacher = data.Teacher, Students = AA.ToArray() }; DataopenCourse.Remove(data); DataopenCourse.Add(item2); return(item2); }