public PersonVM GetPersonById(int id) { var query = new GetPersonByIdQuery(id); var data = _readData.GetPersonById(query); var vm = _mapper.Map <PersonVM>(data); return(vm); }
public override Task <PersonResponse> GetPersonById(PersonSearchRequest request, ServerCallContext context) { var query = new GetPersonByIdQuery(request.Id); var result = Task.FromResult(_mediater.Send(query)); return(Task.FromResult(new PersonResponse { Id = 1, Firstname = "FirstName", Lastname = "Lastname", })); }
public async Task <IActionResult> GetAsync(Guid id, CancellationToken cancellationToken) { var query = new GetPersonByIdQuery(id); var result = await mediator.Send(query, cancellationToken); if (result == null) { return(NotFound()); } return(Ok(result)); }
public async Task GetByIdShouldBeExecutedAsync() { var handler = new GetPersonByIdHandler(_personRepositoryMock.Object); var request = new GetPersonByIdQuery(1); _personRepositoryMock.Setup(x => x.GetById(It.IsAny <int>())).Returns(Task.FromResult(GetMockedPerson())); var person = await handler.Handle(request, CancellationToken.None); Assert.NotNull(person); _personRepositoryMock.Verify(x => x.GetById(It.IsAny <int>()), Times.Once); }
public Person Handle(GetPersonByIdQuery person, IDbConnection db) { return(db.QueryFirst <Person>(sql, person)); }
public Person GetPersonById(GetPersonByIdQuery query) { var data = _messages.Dispatch(query); return(data); }