コード例 #1
0
        public async Task <IActionResult> Create([FromBody] QuestionnaireCreateDTO model)
        {
            try
            {
                // create user
                await _questionnaireService.Create(model, User.Identity.Name);

                return(Ok());
            }
            catch (AppException ex)
            {
                _response         = new ServiceResponse();
                _response.message = ex.Message;
                return(StatusCode(StatusCodes.Status400BadRequest, _response));
            }
            catch (Exception ex)
            {
                _response         = new ServiceResponse();
                _response.message = "Something went wrong, " + ex.Message.ToString();
                return(StatusCode(StatusCodes.Status500InternalServerError, _response));
            }
        }
コード例 #2
0
 public async Task <Guid> Create(QuestionnaireInfo model)
 {
     return(await _questionnaire.Create(model));
 }
コード例 #3
0
 public ActionResult Post([FromBody] QuestionnaireVM questionnaire)
 {
     return(Ok(questionnaireService.Create(questionnaire.Questionnaire)));
 }
コード例 #4
0
        public ActionResult Index(QuestionnaireVm model)
        {
            // _emailService.SendAcountCredentiel(new Domain.Model.User { AdresseEmail = "*****@*****.**", Password = "" });
            Questionnaire questionnaire;
            var           questions = new List <QuestionReponse>();

            foreach (var cat in model.CategorieQuestions)
            {
                foreach (var q in cat.Questions)
                {
                    var questionReponse = new QuestionReponse
                    {
                        QuestionID      = q.Question.QuestionID,
                        ReponseSelected = q.ReponseSelected,
                        ReponseString   = q.ReponseString
                    };

                    questions.Add(questionReponse);
                }
            }
            if (model.QuestionnaireId == 0)
            {
                questionnaire = new Questionnaire();

                questionnaire.Questions    = questions;
                questionnaire.UserId       = SecurityHelper.GetCurrentUserId();
                questionnaire.DateCreation = DateTime.Now;
                //Anayse
                var anlysePointsForts = string.Empty;
                foreach (var q in questions)
                {
                    if (q.ReponseSelected > 0)
                    {
                        var rep = _reponseService.getReponseById(q.ReponseSelected);
                        anlysePointsForts = anlysePointsForts + rep.AnalyseReponsePointsForts;
                    }
                }
                questionnaire.AnalysePointForts = anlysePointsForts;
                _questionnaireService.Create(questionnaire);
            }
            else
            {
                questionnaire = _questionnaireService.getQuestionnaireById(model.QuestionnaireId);
                _questionnaireService.DeleteQuestionReponseByQuestionnaireId(model.QuestionnaireId);
                questionnaire.Questions = questions;
                questionnaire.UserId    = SecurityHelper.GetCurrentUserId();
                //Anayse
                var anlysePointsForts = string.Empty;
                foreach (var q in questions)
                {
                    if (q.ReponseSelected > 0)
                    {
                        var rep = _reponseService.getReponseById(q.ReponseSelected);
                        anlysePointsForts = anlysePointsForts + rep.AnalyseReponsePointsForts;
                    }
                }
                questionnaire.AnalysePointForts = anlysePointsForts;
                _questionnaireService.Update(questionnaire);
            }
            var categories = categorieService.getCategories();

            model = new QuestionnaireVm(categories, questionnaire);
            // return View(model);
            return(RedirectToAction("ListQuestionnaire"));
        }