public IActionResult Post(string values) { var newExam = new Exam(); newExam.examId = new Guid(); newExam.examId = Guid.NewGuid(); JsonConvert.PopulateObject(values, newExam); if (!TryValidateModel(newExam)) { return(BadRequest()); } _db.Exams.Add(newExam); _db.SaveChanges(); return(Ok()); }
public IActionResult Post(string values) { var newquestion = new Question(); newquestion.questionId = new Guid(); newquestion.questionId = Guid.NewGuid(); JsonConvert.PopulateObject(values, newquestion); newquestion.Section = _db.Sections.Where(s => s.sectionId == newquestion.sectionId) .FirstOrDefault(); if (!TryValidateModel(newquestion)) { return(BadRequest()); } _db.Questions.Add(newquestion); _db.SaveChanges(); return(Ok()); }