public async Task <IActionResult> GetRiskAssessmentVisitsDetails(int personId) { var response = await _mediator.Send(new RiskAssessmentVisitQuery() { PersonId = personId }, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <IActionResult> GetHivPartnerProfile(int patientId) { var response = await _mediator.Send(new GetHivPartnerProfileCommand() { PatientId = patientId, }, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <bool> Handle(ResultQuizCommand request, CancellationToken cancellationToken) { var quiz = await _quizRepository.GetAsync(new QuizByIdSpecification(request.QuizId)); if (quiz == null) { _logger.LogError($"Quiz with id {request.QuizId} was not found"); throw new InvalidOperationException($"Quiz with id {request.QuizId} was not found"); } var questions = await _mediator.Send(new GetQuestionsByQuizIdQuery() { QuizId = request.QuizId }, cancellationToken); var quizResult = _checkResultService.CheckResult(questions.Select(x => x.CorrectAnswer).ToList(), request.Answers.ToList()); //var message = _mapper.Map<QuizResultMessage>(quizResults); var message = new QuizResultMessage() { CorrectAnswersCount = quizResult.CorrectAnswersCount, CorrectPercent = quizResult.CorrectPercent, FailedAnswersCount = quizResult.WrongAnswersCount, QuestionsCount = quizResult.QuestionsCount, QuizId = quiz.Id, QuizTitle = quiz.Title, UserId = request.UserId, UserName = "******" }; var endpoint = await _sendEndpointProvider.GetSendEndpoint(message.GetReceiveEndpoint()); await endpoint.Send(message, cancellationToken); return(true); }
public object SendMessage() //where T :IResponse { _mediator.Send(new DataSourceRequest()); return(new object()); }