public async Task <IActionResult> Create([Bind("StudyStatusId,StudyStatusDesc")] StudyStatus studyStatus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studyStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studyStatus));
        }
        public async Task <IActionResult> Create([Bind("TutorTypeId,TutorTypeDesc")] TutorType tutorType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tutorType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tutorType));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("SubjectId,SubjectName,TutorId")] Subject subject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", subject.TutorId);
            return(View(subject));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("StudId,StudName,Email,PhoneNo,StudyStatusId,ClassId")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassId"]       = new SelectList(_context.Class, "ClassId", "ClassId", student.ClassId);
            ViewData["StudyStatusId"] = new SelectList(_context.StudyStatus, "StudyStatusId", "StudyStatusDesc", student.StudyStatusId);
            return(View(student));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("ClassId,ClassDesc,StudyLevelId,TutorId,Year")] Class @class)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@class);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudyLevelId"] = new SelectList(_context.StudyLevel, "StudyLevelId", "StudyLevelDesc", @class.StudyLevelId);
            ViewData["TutorId"]      = new SelectList(_context.Tutor, "TutorId", "TutorId", @class.TutorId);
            return(View(@class));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("TutorName,Email,PhoneNo,TutorStatusId,TutorTypeId")] Tutor tutor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tutor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TutorStatusId"] = new SelectList(_context.TutorStatus, "TutorStatusId", "TutorStatusDesc", tutor.TutorStatusId);
            ViewData["TutorTypeId"]   = new SelectList(_context.TutorType, "TutorTypeId", "TutorTypeDesc", tutor.TutorTypeId);
            return(View(tutor));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("StudSubjectId,StudId,SubjectId")] StudentSubject studentSubject)
        {
            if (ModelState.IsValid)
            {
                if (_context.StudentSubject.Where(x => x.StudId == studentSubject.StudId && x.SubjectId == studentSubject.SubjectId).CountAsync().Result == 0)
                {
                    _context.Add(studentSubject);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Details", "Subjects", new { id = studentSubject.SubjectId }));
                }
                else
                {
                    ViewData["StudId"]  = new SelectList(_context.Student, "StudId", "StudId");
                    ViewData["Subject"] = SetSelected.SetSelectedValue(new SelectList(_context.Subject, "SubjectId", "SubjectName"), studentSubject.SubjectId.ToString());
                    ViewData["Error"]   = "Student has registered the same subject.";
                    return(View());
                }
            }
            return(RedirectToAction("Details", "Subjects", new { id = studentSubject.SubjectId }));
        }
        public async Task <IActionResult> Create(int examId, int[] selectedStudent)
        {
            if (examId != 0 && selectedStudent != null)
            {
                foreach (var item in selectedStudent)
                {
                    _context.Add(new ExamSubject
                    {
                        ExamId        = examId,
                        StudSubjectId = item,
                    });
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            var examSubject = new ExamSubject();

            ViewData["ExamId"]        = new SelectList(_context.Exam, "ExamId", "ExamDesc", examSubject.ExamId);
            ViewData["StudSubjectId"] = new SelectList(_context.StudentSubject, "StudSubjectId", "StudId", examSubject.StudSubjectId);
            return(View(examSubject));
        }