public async Task <StudentWithMarksViewModel> GetStudentWithTheirMarksAsync(int id) { var model = new StudentWithMarksViewModel(); var student = await _context.Students .Include(s => s.Class) .FirstOrDefaultAsync(s => s.Id == id); var marks = await Task.Run(() => _context.Marks .Include(m => m.Subject) .Where(m => m.Student.Id == id) .OrderBy(m => m.Subject.Id)); model.marks = marks; model.student = student; model.StudentClass = student.Class; return(model); }
//testowa klasa public StudentWithMarksViewModel GetStudentWithTheirMarks(string userId) { var model = new StudentWithMarksViewModel(); var student = (Student)_context.Users .Include(u => u.ThePerson) .FirstOrDefault(u => u.Id.Equals(userId.ToString())) .ThePerson; var marks = _context.Marks .Include(m => m.Subject) .Where(m => m.Student.Id == student.Id) .OrderBy(m => m.Subject.Id); model.marks = marks; model.student = student; model.StudentClass = student.Class; return(model); }