예제 #1
0
        public bool Save(SaveQuestionIutputDto inputQuestion)
        {
            QuesList ques = null;

            if (inputQuestion.ID > 0)
            {
                ques = this.questionRepository.FindBy(x => x.ID == inputQuestion.ID).FirstOrDefault();
            }

            if (ques == null)
            {
                ques = new QuesList();
            }

            ques.Question     = inputQuestion.Question;
            ques.Answer       = Cmn.GetCompressed(inputQuestion.Answer);
            ques.AnswerLength = inputQuestion.Answer.Length;
            ques.Language     = inputQuestion.Language;
            ques.Type         = inputQuestion.Type;
            ques.Reviewed     = 1;

            if (inputQuestion.ID == 0)
            {
                this.questionRepository.Add(ques);
            }
            else
            {
                this.questionRepository.Update(ques);
            }

            this.unitOfWork.Commit();
            return(true);
        }
예제 #2
0
        public HttpResponseMessage SaveQuestions(HttpRequestMessage request, SaveQuestionIutputDto inputDTO)
        {
            return(CreateHttpResponse(request, () =>
            {
                var result = this.quesListService.Save(inputDTO);

                if (inputDTO != null)
                {
                    response = request.CreateResponse(HttpStatusCode.OK, new { inputDTO });
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.NotFound, inputDTO.ID.ToString());
                }

                return response;
            }));
        }