コード例 #1
0
ファイル: StudentService.cs プロジェクト: tom8b/SchoolSys
        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);
        }
コード例 #2
0
        //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);
        }