Exemple #1
0
        public async Task <InProgressResponses> CreateNewInProgressResultsRepository(int ParticipantId, int SurveyId, InProgResponse[] responses)
        {
            InProgressResponses NewResponsesObject = new InProgressResponses();

            NewResponsesObject.SurveyId      = SurveyId;
            NewResponsesObject.ParticipantId = ParticipantId;
            if (SurveyId == 1)
            {
                NewResponsesObject.SurveyName = "Personality Survey";
            }
            else if (SurveyId == 2)
            {
                NewResponsesObject.SurveyName = "Diary Survey";
            }
            else if (SurveyId == 5)
            {
                NewResponsesObject.SurveyName = "Final Survey";
            }
            else
            {
                NewResponsesObject.SurveyName = "Invalid Survey Id";
            }
            await _Data.InProgressResponses.AddAsync(NewResponsesObject);

            _Data.SaveChanges();

            await CreateResponses(NewResponsesObject.ParticipantId, NewResponsesObject.SurveyId, NewResponsesObject.InProgressResponsesId, responses);

            return(NewResponsesObject);
        }
Exemple #2
0
        public async Task <InProgressResponses> GetResponses(int participantId, int surveyId, InProgResponse[] responsesFromSurvey)
        {
            InProgressResponses responses = _Data.InProgressResponses.Where(p => p.ParticipantId == participantId).FirstOrDefault();

            if (responses != null)
            {
                _Data.InProgressResponses.Remove(responses);
                await _Data.SaveChangesAsync();
            }

            await CreateNewInProgressResultsRepository(participantId, surveyId, responsesFromSurvey);

            return(responses);
        }
Exemple #3
0
 public string DeleteResponses(InProgressResponses responsesToDelete)
 {
     _Data.InProgressResponses.Remove(responsesToDelete);
     _Data.SaveChanges();
     return(null);
 }