public IActionResult Create(Exam exam)
 {
     if (ModelState.IsValid)
     {
         _context.Exams.Add(exam);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(exam));
 }
예제 #2
0
 public IActionResult Create(RegExam regExam)
 {
     if (ModelState.IsValid)
     {
         _context.RegExam.Add(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));
 }
        public async Task <IActionResult> Create(Faculty faculty, string Password)
        {
            if (ModelState.IsValid)
            {
                _context.Faculty.Add(faculty);
                _context.SaveChanges();
                var result = await _seeder.CreateFacultyIdentityUser(faculty, Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(faculty));
        }
예제 #4
0
        public async Task <IActionResult> Create(Student student, string Password)
        {
            if (ModelState.IsValid)
            {
                _context.Students.Add(student);
                _context.SaveChanges();
                var result = await _seeder.CreateStudentIdentityUser(student, Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(student));
        }
        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"));
        }
예제 #6
0
        public IActionResult CreateOrUpdate(Question model)
        {
            if (model.QuestionId > 0)
            {
                Question question = context.Questions.Find(model.QuestionId);
                question.Question1     = model.Question1;
                question.QuestionLevel = model.QuestionLevel;
                question.Answer        = model.Answer;

                context.Questions.Update(question);
                context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                context.Questions.Add(model);
                context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
        }