public HttpResponseMessage SaveQuestion(HttpRequestMessage request, SaveMultipleChoiceInputDto inputDTO)
 {
     return(CreateHttpResponse(request, () =>
     {
         var results = this.multipleChoiceService.SaveMultipleChoice(inputDTO);
         response = request.CreateResponse(HttpStatusCode.OK, new { results });
         return response;
     }));
 }
예제 #2
0
        public bool SaveMultipleChoice(SaveMultipleChoiceInputDto inputDTO)
        {
            MultipleChoice mc = null;

            if (inputDTO.ID > 0)
            {
                mc = this.multipleChoiceRepository.FindBy(x => x.ID == inputDTO.ID).FirstOrDefault();
            }

            if (mc == null)
            {
                mc = new MultipleChoice();
            }

            mc.Language = inputDTO.Language;
            mc.Question = inputDTO.Question;
            mc.Option1  = inputDTO.Option1;
            mc.Option2  = inputDTO.Option2;
            mc.Option3  = inputDTO.Option3;
            mc.Option4  = inputDTO.Option4;
            mc.Option5  = inputDTO.Option5;
            mc.Answer   = inputDTO.Answer;

            if (inputDTO.ID == 0)
            {
                this.multipleChoiceRepository.Add(mc);
            }
            else
            {
                this.multipleChoiceRepository.Update(mc);
            }

            this.unitOfWork.Commit();

            return(true);
        }