public void DeleteExam(Guid key) { var question = _db.QuestionExams.First(a => a.QuestionId == key); _db.QuestionExams.Remove(question); _db.SaveChanges(); }
public IActionResult Post(string values) { var newSubject = new Subject(); newSubject.SubjectId = new Guid(); JsonConvert.PopulateObject(values, newSubject); _db.Subjects.Add(newSubject); _db.SaveChanges(); return(Ok()); }
public IActionResult Post(string values) { var newExam = new Exam(); newExam.ExamCodeId = new Guid(); newExam.ExamCodeId = Guid.NewGuid(); JsonConvert.PopulateObject(values, newExam); _db.Exams.Add(newExam); _db.SaveChanges(); return(Ok()); }
public ActionResult IndexPost(Guid id, Question question) { var _question = _db.Questions.First(a => a.QuestionId == id); _question.QuestionStr = question.QuestionStr; _question.Hint = question.Hint; _question.QuestionLevel = question.QuestionLevel; _question.QuestionType = question.QuestionType; _question.TopicId = question.TopicId; _question.QuestionPoint = question.QuestionPoint; _db.SaveChanges(); return(RedirectToAction("Index", "Questions")); }
public IActionResult Post(string values) { var newUser = new ExamTesting.Models.User() { UserId = new Guid() }; JsonConvert.PopulateObject(values, newUser); _db.Users.Add(newUser); _db.SaveChanges(); return(Ok()); }
public IActionResult QuestionAnswer(Guid id) { var _exams = _db.UserExamQuestions.Where(a => a.UserExamQuestionId == id).ToList(); foreach (var _question in _exams) { _exams.ForEach(e => { if (e.QuestionId == _question.QuestionId) { _db.SaveChanges(); } }); return(View(_question)); } return(View(_exams)); }
public IActionResult AddQuestions(Guid id, string questionsString) { var _exam = _db.Exams.First(a => a.ExamCodeId == id); List <Question> questionsList = JsonConvert.DeserializeObject <List <Question> >(questionsString); _exam.AddQuestionns(questionsList); _db.SaveChanges(); return(RedirectToAction("Questions", "Exam", new { id = id })); }
public IActionResult AddExams(string examsString) { var _user = _db.Users.First(a => a.UserId == CurrentUserId); List <Exam> examList = JsonConvert.DeserializeObject <List <Exam> >(examsString); _user.AddExams(examList); _db.SaveChanges(); return(RedirectToAction("Index", "Exams")); }
public IActionResult Process(LoginViewModel model) { if (model.PasswordCheck) { var newUser = new ExamTesting.Models.User() { UserId = Guid.NewGuid(), Email = model.Email, Name = model.Name, Password = model.Password }; _db.Users.Add(newUser); _db.SaveChanges(); } else { return(View("Index")); } return(RedirectToAction("Index", "SignIn", null)); }