Пример #1
0
        private StudentEditViewModel GetStudentViewModel(int Id)
        {
            studentId = Id;
            var student       = _studentDAO.FetchAllRecords().SingleOrDefault(s => s.Id == studentId);
            var studentQuests = _ownedQuestStudentDAO.FetchAllRecords().Where(q => q.StudentId == student.Id).ToList();
            var quests        = _questDAO.FetchAllRecords();

            var ownedStudentQuests = quests
                                     .Join(studentQuests, q => q.Id, s => s.QuestId, (q, s) => new OwnedQuestStudent
            {
                Id = s.Id, StudentId = s.StudentId, QuestId = s.QuestId, CompletionStatus = s.CompletionStatus, Name = q.Name, Cost = q.Cost
            })
                                     .OrderBy(q => q.CompletionStatus)
                                     .ToList();

            var classrooms = _classroomDAO.FetchAllRecords().Where(c => c.Id == student.ClassID).ToList();
            var groups     = _groupDAO.FetchAllRecords().Where(g => g.Id == student.GroupID).ToList();


            var studentEVM = new StudentEditViewModel
            {
                Id                 = student.Id,
                CredentialID       = student.CredentialID,
                ClassID            = student.ClassID,
                GroupID            = student.GroupID,
                FirstName          = student.FirstName,
                LastName           = student.LastName,
                Wallet             = student.Wallet,
                Classrooms         = classrooms,
                Groups             = groups,
                OwnedStudentQuests = ownedStudentQuests
            };

            return(studentEVM);
        }
Пример #2
0
 public IActionResult Index()
 {
     return(View(_classroomDAO.FetchAllRecords().OrderBy(c => c.Id)));
 }