public List<Student> GetStudentsByTeacherUsername(string user) { var teacherId = new GetTeachers().GetTeacherIdByUsername(user); var markList = new GetMarks().GetMarksByTeacherId(teacherId).Where(m => m.SubjectId.Equals(1)); List<Student> students = new List<Student>(); foreach (var x in markList) { students.Add(GetStudentById(x.StudentId)); } return students; }
public List<Teacher> GetTeachersByStudentId(int id) { var markList = new GetMarks().GetMarksByStudentId(id); //var subjectList = subjects.GetSubjectByMarkId(.id; List<Subject> subjectList = new List<Subject>(); foreach(var x in markList) { subjectList.Add(new GetSubjects().GetSubjectByMarkId(x.Id)); } List<Teacher> teachers = new List<Teacher>(); foreach (var x in subjectList) { teachers.Add(GetTeacherById(x.Id)); } return teachers; }
public ActionResult DeleteConfirmed(int id) { Student student = db.Students.Find(id); db.Students.Remove(db.Students.Find(id)); var marks = new GetMarks().GetMarksByStudentId(id); for (int i = 0; i < marks.Count; i++) { db.StudentMark.Remove(db.StudentMark.Find(marks[i].Id)); } db.SaveChanges(); return RedirectToAction("Index"); }