public IActionResult Register(Exam exam)
        {
            var     emc           = new ExamManagementContext();
            var     loggedStudent = emc.Students.Where(s => s.UserName == User.Identity.Name).First();
            var     regExams      = emc.RegExam.Where(e => e.studentID == loggedStudent.studentID).ToList();
            var     matchedExam   = regExams.Where(e => e.examID == exam.examID);
            RegExam updatedExam   = new RegExam();

            if (matchedExam.Count() > 0)
            {
                updatedExam          = matchedExam.First();
                updatedExam.withdraw = "0";
            }
            else
            {
                updatedExam.examID     = exam.examID;
                updatedExam.studentID  = loggedStudent.studentID;
                updatedExam.registered = "1";
                updatedExam.publish    = "0";
                updatedExam.withdraw   = "0";
            }
            emc.Update(updatedExam);
            emc.SaveChanges();

            return(RedirectToAction("AvailExams"));
        }
 public IActionResult Edit(Faculty faculty)
 {
     if (ModelState.IsValid)
     {
         _context.Update(faculty);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(faculty));
 }
Beispiel #3
0
 public IActionResult Edit(Student student)
 {
     if (ModelState.IsValid)
     {
         _context.Update(student);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
 public IActionResult Edit(Exam exam)
 {
     if (ModelState.IsValid)
     {
         _context.Update(exam);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(exam));
 }
        public async Task <IActionResult> Edit(Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Update(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(student));
        }
Beispiel #6
0
 public IActionResult Edit(RegExam regExam)
 {
     if (ModelState.IsValid)
     {
         _context.Update(regExam);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["examID"]    = new SelectList(_context.Exams, "examID", "Exam", regExam.examID);
     ViewData["studentID"] = new SelectList(_context.Students, "studentID", "Student", regExam.studentID);
     return(View(regExam));
 }