Exemplo n.º 1
0
        public async Task <string> CreateResponseEntry(string participantId, ResponseDto[] responses, int surveyId)
        {
            int             responseNumber = 0;
            CompletedSurvey survey         = await CreateNewCompletedSurveyObject(participantId, surveyId);

            List <Response> responsesForDb = new List <Response>();

            for (int x = 0; x < responses.Length; x++)
            {
                if (responses[x] == null)
                {
                    continue;
                }
                for (int y = 0; y < responses[x].Responses.Length; y++)
                {
                    Response response = new Response
                    {
                        Answer            = responses[x].Responses[y],
                        QuestionId        = responses[x].QuestionId,
                        QuestionAsked     = responses[x].QuestionAsked,
                        CompletedSurveyId = survey.CompletedSurveyId
                    };
                    _data.Add(response);
                }
            }
            _data.SaveChanges();
            return("success");
        }
Exemplo n.º 2
0
        public async Task <CompletedSurvey> CreateNewCompletedSurveyObject(string participantId, int surveyId)
        {
            CompletedSurvey survey = new CompletedSurvey
            {
                ParticipantId = participantId,
                SurveyId      = surveyId
            };

            _data.Add(survey);
            _data.SaveChanges();
            return(survey);
        }