Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("EnrollId,CourseId,StudentId")] EnrolledIn enrolledIn)
        {
            if (id != enrolledIn.EnrollId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrolledIn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrolledInExists(enrolledIn.EnrollId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Courses, "CourseId", "CourseId", enrolledIn.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "StudentId", enrolledIn.StudentId);
            return(View(enrolledIn));
        }
        public bool EnrollStudent(int studentId, int courseId)
        {
            var enrolledIn = new EnrolledIn
            {
                StudentId   = studentId,
                CourseId    = courseId,
                StudentYear = ""
            };

            context.EnrolledIns.Add(enrolledIn);

            return(SaveDB());
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("EnrollId,CourseId,StudentId")] EnrolledIn enrolledIn)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrolledIn);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Courses, "CourseId", "CourseId", enrolledIn.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "StudentId", enrolledIn.StudentId);
            return(View(enrolledIn));
        }
        public bool EnrollStudents(int[] studentIds, int courseId)
        {
            foreach (var id in studentIds)
            {
                var enrolledIn = new EnrolledIn
                {
                    StudentId   = id,
                    CourseId    = courseId,
                    StudentYear = ""
                };
                context.EnrolledIns.Add(enrolledIn);
            }

            return(SaveDB());
        }
Beispiel #5
0
        private async Task LoadEnrolledSessionsAsync()
        {
            EnrolledIn.Clear();
            var enrolledSessions = await _Repository.Enrollment.GetRangeAsync(c => c.CandidateId == Model.CandidateId);

            foreach (var enrolledSession in enrolledSessions)
            {
                var getSession = _Repository.Session.Get(c => c.SessionId == enrolledSession.SessionCode);
                var getCourse  = _Repository.Course.Get(c => c.CourseId == getSession.CourseId);
                getSession.Course       = getCourse;
                enrolledSession.Session = getSession;

                EnrolledIn.Add(new EnrolleeModel(enrolledSession, _Repository));
                await Task.Delay(100);
            }
        }