コード例 #1
0
 public void CreateConsideration(InActive.Consideration Consideration)
 {
     if (Consideration != null)
     {
         var coltn = helper.GetCollection <InActive.Consideration>(InactiveSubject_Consideration);
         coltn.InsertOne(Consideration);
     }
     else
     {
         throw new ArgumentNullException("null input from Consideration");
     }
 }
コード例 #2
0
        public Consideration ConsiderQuestion(string TitleCode, int QuestionNumber, [FromBody] Consideration consideration)
        {
            var _consideration = new InActive.Consideration()
            {
                _id            = repoForApprove.GetNewGuid("").ToString(),
                CreateDateTime = DateTime.Now,
                RejectComment  = consideration?.RejectComment,
                IsAccept       = consideration?.IsAccept ?? false,
                UserName       = consideration?.UserName, //TODO : userName ??
                ExamSuiteId    = consideration.ExamSuiteId,
                QuestionNumber = QuestionNumber,
            };

            var preConsiderationExamSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId);
            var preStatus = repoForApprove.GetConsiderationStatus(preConsiderationExamSuite);

            repoForApprove.CreateConsideration(_consideration);
            var postConsiderationExamSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId);
            var postStatus = repoForApprove.GetConsiderationStatus(postConsiderationExamSuite);

            var examSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId);
            var subject = repoQ.GetInActiveSubject(examSuite.SubjectId);
            int ExamSuiteAcceptCount = subject.ExamSuiteAcceptCount, ExamSuiteRejectCount = subject.ExamSuiteRejectCount;

            if (preStatus == "Accepted" && postStatus == "Rejected")
            {
                ExamSuiteAcceptCount--;
                ExamSuiteRejectCount++;
            }
            else if (preStatus == "Rejected" && postStatus == "Accepted")
            {
                ExamSuiteAcceptCount++;
                ExamSuiteRejectCount--;
            }
            else if (preStatus == "Wait" && postStatus == "Accepted")
            {
                ExamSuiteAcceptCount++;
            }
            else if (preStatus == "Wait" && postStatus == "Rejected")
            {
                ExamSuiteRejectCount++;
            }
            repoQ.UpdateQuestionCountComment(examSuite.SubjectId, ExamSuiteAcceptCount, ExamSuiteRejectCount);

            consideration.id             = _consideration._id;
            consideration.CreateDateTime = _consideration.CreateDateTime;
            consideration.ExamSuiteId    = consideration.ExamSuiteId;
            consideration.QuestionNumber = QuestionNumber;
            return(consideration);
        }