public IActionResult Search([FromQuery] Response response, [FromQuery] Answer answer, [FromQuery] Question question, [FromQuery] Period period, QuestionType questionType, [FromQuery] Agent agent, [FromQuery] string isActiveAgent, [FromQuery] string isOpen, [FromQuery] string hasAnswers) { try { IEnumerable <Response> responses = responseManager.Find(x => x.ResponseId == response.ResponseId && x.ResponseText == response.ResponseText && x.Answer.AnswerId == answer.AnswerId && x.Answer.AnswerText == answer.AnswerText && x.Answer.AnswerSort == answer.AnswerSort && x.Answer.Question.QuestionTypeId == question.QuestionTypeId && x.Answer.Question.PeriodId == question.PeriodId && x.Answer.Question.Period.StartDate == period.StartDate && x.Answer.Question.Period.EndDate == period.EndDate && x.Answer.Question.QuestionText == question.QuestionText && x.Answer.Question.QuestionSort == question.QuestionSort && x.Answer.Question.QuestionType.Description == questionType.Description && x.Agent.AgencyCode == agent.AgencyCode && x.Agent.AgencyName == agent.AgencyName); if (!string.IsNullOrWhiteSpace(isOpen)) { bool isOp; bool.TryParse(isOpen, out isOp); responses = responses.Where(x => x.Answer.Question.Period.IsOpen == isOp); } if (!string.IsNullOrWhiteSpace(hasAnswers)) { bool hasAns; bool.TryParse(hasAnswers, out hasAns); responses = responses.Where(x => x.Answer.Question.QuestionType.HasAnswers == hasAns); } if (!string.IsNullOrWhiteSpace(isActiveAgent)) { bool isActive; bool.TryParse(isActiveAgent, out isActive); responses = responses.Where(x => x.Agent.IsActiveAgent == isActive); } return(Ok(responses)); } catch (Exception ex) { logger.LogError($"Failed to find response(s): {ex}"); return(BadRequest(config["Error:Default"])); } }
public IActionResult Responses(int id) { try { IEnumerable <Response> responses = responseManager.Find(x => x.AnswerId == id); return(Ok(responses)); } catch (Exception ex) { logger.LogError($"Failed to get responses for answer {id}: {ex}"); return(BadRequest(config["Error:Default"])); } }