public static Exam EditedRealToExam(RealExam editedReal, ExamController examController) { Exam editedExam = examController.GetById(editedReal.Id); editedExam.fromDate = DateTime.Parse(editedReal.fromDate); editedExam.untilDate = DateTime.Parse(editedReal.untilDate); editedExam.subAreaId = editedReal.subAreaId; editedExam.staticQuestions = editedReal.staticQuestions; editedExam.numberQuestions = editedReal.numberQuestions; editedExam.title = editedReal.title; return(editedExam); }
public RealExam GetRealExam(int id) { RealExam cachedExam = realExamsCache.Find(realExam => realExam.Id == id); if (cachedExam == null) { DAL.Exam exam = examController.GetById(id); if (!exam.staticQuestions) { return(GetRandomExam(exam)); } RealExam newExam = realExamController.GetStaticExamModel(exam); realExamsCache.Add(newExam); System.Diagnostics.Debug.WriteLine("Exam fetched is:" + newExam.title); return(newExam); } if (!cachedExam.staticQuestions) { return(GetRandomExam(examController.GetById(id))); } System.Diagnostics.Debug.WriteLine("Exam cached is:" + cachedExam.title); return(cachedExam); }
public void Post([FromBody] object realExam) { JObject juser = realExam as JObject; RealExam recievingRealExam = juser.ToObject <RealExam>(); Exam modelExam = examController.GetById(recievingRealExam.Id); RealExam realModelExam; if (!modelExam.staticQuestions) { realModelExam = realExamController.GetRandomExamModel(recievingRealExam); } else { realModelExam = realExamController.GetStaticExamModel(modelExam); } EvaluateAndRegister(recievingRealExam, realModelExam); }