public IHttpActionResult AddUserInfoAnswerRecord(AddUserInfoAnswerRecordDto addUserInfoAnswerRecordDto) { var belong = belongService.GetById(addUserInfoAnswerRecordDto.BelongId); var chapter = chapterService.GetById(addUserInfoAnswerRecordDto.ChapterId); string title = (belong != null ? belong.Title : "") + "-" + (chapter != null ? chapter.Title : ""); var userInfoAnswerRecord = userInfoAnswerRecordService.GetById(addUserInfoAnswerRecordDto.UserInfoAnswerRecordId); if (userInfoAnswerRecord == null) { userInfoAnswerRecord = new UserInfoAnswerRecord(); userInfoAnswerRecord = userInfoAnswerRecordService.Insert(new Domain.Model.UserInfoAnswerRecord { BelongId = addUserInfoAnswerRecordDto.BelongId, ChapterId = addUserInfoAnswerRecordDto.ChapterId, Score = 0, CTime = DateTime.Now, UTime = DateTime.Now, UserInfoId = addUserInfoAnswerRecordDto.UserInfoId, Title = title }); } var problemlist = problemService.GetProblemList(addUserInfoAnswerRecordDto.BelongId, addUserInfoAnswerRecordDto.ChapterId, addUserInfoAnswerRecordDto.SubjectInfoId); foreach (var item in addUserInfoAnswerRecordDto.AddProblemRecordDto) { var problem = (from a in problemlist where a.ProblemId == item.ProblemId select a).FirstOrDefault(); if (problem != null) { int ErrorAnswer = item.ProblemId; if (problem.ProblemId == item.ProblemId) { ErrorAnswer = problem.ProblemId; } var answer = (from b in problem.AnswerList where b.IsCorrect == 1 select b).ToList(); string CorrectAnswer = string.Empty; foreach (var a in answer) { CorrectAnswer += a.AnswerId + ","; } if (CorrectAnswer.Length > 0) { CorrectAnswer = CorrectAnswer.Substring(0, CorrectAnswer.Length - 1); } var problemRecord = problemRecordService.Insert(new Domain.Model.ProblemRecord { CTime = DateTime.Now, UTime = DateTime.Now, Title = problem.Title, CorrectAnswer = CorrectAnswer, ErrorAnswer = item.AnswerIds, ProblemCategoryId = problem.ProblemCategoryId, ProblemId = item.ProblemId, UserInfoAnswerRecordId = userInfoAnswerRecord.UserInfoAnswerRecordId, Analysis = problem.Analysis, YesOrNo = item.YesOrNo, UserInfoId = addUserInfoAnswerRecordDto.UserInfoId }); foreach (var itemChild in problem.AnswerList) { answerRecordService.Insert(new Domain.Model.AnswerRecord { AnswerId = itemChild.AnswerId, ProblemId = problem.ProblemId, IsCorrect = itemChild.IsCorrect, ProblemRecordId = problemRecord.ProblemRecordId, Title = itemChild.Title }); } } } return(Json(new { Success = true, Msg = "OK", Data = "" })); }
/// <summary> /// 编辑 /// </summary> /// <param name="_BelongVM"></param> /// <returns></returns> public ActionResult Edit(BelongVM _BelongVM) { _BelongVM.Belong = _BelongService.GetById(_BelongVM.Id) ?? new Belong(); return(View(_BelongVM)); }