コード例 #1
0
        // GET: Student/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            Student student = await _studentRepositoryAsync.GetByIdAsync(id);

            StudentAddViewModel model = new StudentAddViewModel
            {
                Student = student
            };

            return(View(model));
        }
コード例 #2
0
        // GET: Relationship/StudentLessons
        public async Task <ActionResult> StudentLessons(string user, long id)
        {
            try
            {
                Teacher teacher = await _teacherRepositoryAsync.GetByUserAsync(user);

                List <Student> Students = await _studentRepositoryAsync.ListByUserAsync(user);

                Student student = await _studentRepositoryAsync.GetByIdAsync(id);

                List <StudentLesson> studentLessons  = student.StudentLessons;
                List <long>          assignedLessons = new List <long>();

                foreach (var lesson in studentLessons)
                {
                    assignedLessons.Add(lesson.LessonId);
                }

                RelationshipViewModel model = new RelationshipViewModel
                {
                    Teacher         = teacher,
                    Student         = student,
                    StudentLessons  = studentLessons,
                    AssignedLessons = assignedLessons
                };

                return(View(model));
            }
            catch (Exception)
            {
                throw;
            }
        }