public async Task <IActionResult> AddItem(QuestionForAddDto QuestionForAddDto) { var question = new Question { Content = QuestionForAddDto.Content, Url = QuestionForAddDto.Url, TypeId = QuestionForAddDto.TypeId }; _repo.Add(question); if (await _repo.SaveAll()) { var questionToReturn = _mapper.Map <Question>(question); foreach (var answer in QuestionForAddDto.Answer) { var ans = new Answer { Content = answer.Content, QuestionId = question.Id, AnswerTrue = answer.AnswerTrue }; _repo.Add(ans); await _repo.SaveAll(); } return(CreatedAtRoute("GetQuestion", new { id = question.Id }, questionToReturn)); } return(BadRequest("Could not add the photo")); }
public bool GenerateExam(GenerateExamVM examVM, int tecaherId) { //questionsand typings are received into examVM var exam = new Exam { WiredTypingTitle = examVM.Exam.WiredTypingTitle, WiredTypingContent = examVM.Exam.WiredTypingContent, UserId = tecaherId, Questions = new List <Question>(), CreateDate = DateTime.Now }; foreach (var question in examVM.Exam.Questions) { exam.Questions.Add(new Question { Choice_A = question.Choice_A, Choice_B = question.Choice_B, Choice_C = question.Choice_C, Choice_D = question.Choice_D, CorrectChoice = question.CorrectChoice, CreateDate = DateTime.Now, QuestionText = question.QuestionText, }); } return(_examRepo.Add(exam)); }
public async Task <MessageModel <string> > Post([FromBody] Exam Exam) { var data = new MessageModel <string>(); var id = await _iExamRepository.Add(Exam); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return(data); }
public void CreateExam(Exam exam) { if (_examRepository.GetById(exam.Id) != null) { throw new ArgumentOutOfRangeException(); } _examRepository.Add(exam); foreach (var stud in _studentRepository.GetAll()) { foreach (var course in _courseRepository.GetAll()) { if (stud.StudyYear == course.StudyYear && course.Id == exam.CourseId) { var grade = new Grade(stud.Id, exam.Id, 0, 0); _gradeRepostory.Add(grade); } } } }
public IActionResult Create(ExamViewModel model) { if (model.StartDate == DateTime.MinValue) { model.StartDate = DateTime.Now; } if (model.EndDate == DateTime.MinValue) { model.EndDate = DateTime.Now.AddYears(10); } Exam exam = new Exam { Name = model.Name, Duration = model.Duration, StartDate = model.StartDate, EndDate = model.EndDate, CourseId = model.CourseId }; examRepository.Add(exam); return(RedirectToAction("Index", new { courseId = model.CourseId })); }
public void CreateExam(Exam exam) { examRepository.Add(exam); }
public int AddExam(DLModel.Exam exam) { return(_examRepository.Add(exam).ExamID); }
public int Add(Exam entity) { _examRepository.Add(entity); return(entity.ID); }
public void Add(Exam entity) { _examRepository.Add(entity); }