Пример #1
0
        public async Task <ActionResult <Patient> > GetPatient(int id)
        {
            var query  = new GetPatientQuery(id);
            var result = await _mediator.Send(query);

            return(result != null ? (ActionResult)Ok(result) : NotFound());
        }
Пример #2
0
        public async Task <ActionResult <PatientReadModel> > GetById(Guid patientId)
        {
            var query           = new GetPatientQuery(patientId);
            var doctorReadModel = await _getPatientQueryHandler.HandleAsync(query);

            return(Ok(doctorReadModel));
        }
        public async Task <ActionResult <BaseResponse <Patient> > > GetPatient(string id)
        {
            var query  = new GetPatientQuery(id);
            var result = await _mediator.Send(query);

            return(Ok(result));
        }
Пример #4
0
        public async Task Handle_NoMatchingId_ThrowsNotFoundException()
        {
            var query = new GetPatientQuery {
                Id = 3
            };

            var handler = new GetPatientQuery.GetPatientQueryHandler(_context, _mapper);

            Func <Task> action = () => handler.Handle(query, CancellationToken.None);

            await action.Should().ThrowExactlyAsync <NotFoundException>();
        }
Пример #5
0
        public async Task Handle_ReturnsCorrectVmAndPatient()
        {
            var query = new GetPatientQuery {
                Id = 1
            };

            var handler = new GetPatientQuery.GetPatientQueryHandler(_context, _mapper);

            var result = await handler.Handle(query, CancellationToken.None);

            result.Should().BeOfType <GetPatientVm>();
            result.Id.Should().Be(1);
            result.Honorific.Should().Be(Honorific.Mr);
            result.FirstName.Should().Be("Jay");
        }
Пример #6
0
        public async Task <ActionResult> Get(int id)
        {
            _logger.LogInformation($"Entering {nameof(Get)}/{id}");

            GetPatientQuery query = new GetPatientQuery {
                PatientId = id
            };

            var validationErrors = new GetPatientQueryValidator().Validate(query).Errors;

            if (validationErrors.Any())
            {
                throw new ValidationException(validationErrors.ToList());
            }

            return(Ok(await _mediator.Send(query)));
        }