Exemplo n.º 1
0
        private async Task <PostFeedback> UpdateFeedbackQuestionAndAnswers(PostFeedback postFeedback)
        {
            FeedbackQuestion feedbackQuestion = new FeedbackQuestion();

            feedbackQuestion.Question        = postFeedback.Question;
            feedbackQuestion.QuestionTye     = postFeedback.QuestionTye;
            feedbackQuestion.ParticipantType = postFeedback.ParticipantType;
            feedbackQuestion.Id = postFeedback.Id;

            feedbackQuestion = await _fbQuestionRepository.Update(feedbackQuestion);

            var allOptions = await _fbOptionRepository.GetAll();

            var questionOptions = allOptions.Where(x => x.QuestionId == feedbackQuestion.Id).ToList();

            foreach (FeedbackOption opt in questionOptions)
            {
                await _fbOptionRepository.Delete(opt.Id);
            }
            foreach (string fbOption in postFeedback.FeedbackOptions)
            {
                FeedbackOption option = new FeedbackOption();
                option.Option     = fbOption;
                option.QuestionId = feedbackQuestion.Id;
                await _fbOptionRepository.Add(option);
            }
            return(postFeedback);
        }
Exemplo n.º 2
0
 public async Task <PostFeedback> SaveFeedbackQuestionAndAnswers(PostFeedback postFeedback)
 {
     if (postFeedback.Id == 0)
     {
         return(await InsertFeedbackQuestionAndAnswers(postFeedback));
     }
     else
     {
         return(await UpdateFeedbackQuestionAndAnswers(postFeedback));
     }
 }
Exemplo n.º 3
0
        public async Task SaveFbQstnAndAnsAsync_ShouldSaveFbQstnAndAns()
        {
            PostFeedback postFeedback = new PostFeedback();

            postFeedback.ParticipantType = "Participated";
            PostFeedback resultFeedback = new PostFeedback();

            resultFeedback.ParticipantType = "Participated";
            resultFeedback.QuestionTye     = "MultipleAnswer";

            _feedbackRepository.Setup(x => x.SaveFeedbackQuestionAndAnswers(postFeedback)).ReturnsAsync(resultFeedback);
            PostFeedback result = await feedbackController.Post(postFeedback);

            Assert.AreEqual(result.QuestionTye, "MultipleAnswer");
        }
Exemplo n.º 4
0
        //------------------ End :: Function ------------------
        #endregion End :: SubmitPost Information

        #region Start :: Post Feed Back Information

        //------------------ Start :: Function ------------------
        public ActionResult SavePostFeedback(PostFeedback objItem)
        {
            ALLMENU allMenu = new ALLMENU();

            allMenu = (ALLMENU)Session["Menu"];
            if (allMenu != null)
            {
                DBPostFeedback objDB = new DBPostFeedback();
                return(Json(objDB.SavePostFeedback(objItem, allMenu.ListObjMenuPermission[0].UserID.ToString())));
            }
            else
            {
                return(Json(new { JsonData = "", IsLogin = "******", redirectUrl = Url.Action("Index", "Security") }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
        public async Task PostFbQuestionsByPartIdAsync_ShouldPostFbQuestionsByPartId()
        {
            PostFeedback postFeedback = new PostFeedback();

            postFeedback.ParticipantType = "Participated";
            List <FeedbackVM> feedbackVMs = new List <FeedbackVM>();
            FeedbackVM        feedback    = new FeedbackVM()
            {
                Id          = 1,
                Question    = "How is the event?",
                QuestionTye = "MultipleAnswer"
            };

            feedbackVMs.Add(feedback);
            _feedbackRepository.Setup(x => x.GetFeedbackQuestionsByParticipantType(postFeedback)).ReturnsAsync(feedbackVMs);
            IEnumerable <FeedbackVM> result = await feedbackController.PostFeedbackQuestionsByParticipantType(postFeedback);

            Assert.IsNotEmpty(result);
        }
Exemplo n.º 6
0
        private async Task <PostFeedback> InsertFeedbackQuestionAndAnswers(PostFeedback postFeedback)
        {
            FeedbackQuestion feedbackQuestion = new FeedbackQuestion();

            feedbackQuestion.Question        = postFeedback.Question;
            feedbackQuestion.QuestionTye     = postFeedback.QuestionTye;
            feedbackQuestion.ParticipantType = postFeedback.ParticipantType;

            feedbackQuestion = await _fbQuestionRepository.Add(feedbackQuestion);

            foreach (string fbOption in postFeedback.FeedbackOptions)
            {
                FeedbackOption option = new FeedbackOption();
                option.Option     = fbOption;
                option.QuestionId = feedbackQuestion.Id;
                await _fbOptionRepository.Add(option);
            }
            return(postFeedback);
        }
Exemplo n.º 7
0
 public async Task <PostFeedback> Post([FromBody] PostFeedback postFeedback)
 {
     return(await _repository.SaveFeedbackQuestionAndAnswers(postFeedback));
 }
Exemplo n.º 8
0
 public async Task <IEnumerable <FeedbackVM> > PostFeedbackQuestionsByParticipantType([FromBody] PostFeedback postFeedback)
 {
     return(await _repository.GetFeedbackQuestionsByParticipantType(postFeedback));
 }
Exemplo n.º 9
0
        public async Task <IEnumerable <FeedbackVM> > GetFeedbackQuestionsByParticipantType(PostFeedback postFeedback)
        {
            List <FeedbackVM> allQuestions = new List <FeedbackVM>();

            var fbAllQuestions = await _fbQuestionRepository.GetAll();

            var participantQns = fbAllQuestions.Where(x => x.ParticipantType == postFeedback.ParticipantType).ToList();

            foreach (var fbQuestion in participantQns)
            {
                FeedbackVM feedbackVM = new FeedbackVM();
                feedbackVM.Id              = fbQuestion.Id;
                feedbackVM.Question        = fbQuestion.Question;
                feedbackVM.ParticipantType = fbQuestion.ParticipantType;
                feedbackVM.QuestionTye     = fbQuestion.QuestionTye;

                var questionOptions = await _fbOptionRepository.GetAll();

                List <FeedbackOption> options = questionOptions.Where(x => x.QuestionId == fbQuestion.Id).ToList();
                feedbackVM.FeedbackOptions = options;

                allQuestions.Add(feedbackVM);
            }

            return(allQuestions);
        }