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); }
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); }