public async Task <SearchEmployeeByIdQueryResponse> SearchEmployeeByIdAsync(SearchEmployeeByIdQueryRequest queryRequest) { return(await paymentsControlDataContext .connection .QueryFirstOrDefaultAsync <SearchEmployeeByIdQueryResponse>("spSearchEmployeeById", new { queryRequest.Id }, commandType : CommandType.StoredProcedure)); }
public async Task <IActionResult> SearchEmployeeById([FromRoute] SearchEmployeeByIdQueryRequest queryRequest) { var queryResponse = await mediator.Send(queryRequest); switch (queryResponse.Status) { case true: return(Ok(queryResponse)); case false: return(BadRequest(queryResponse)); } }
public async Task <HandlerResultEntity <SearchEmployeeByIdQueryResponse> > Handle(SearchEmployeeByIdQueryRequest queryRequest, CancellationToken cancellationToken) { var validationResult = await validator.ValidateAsync(queryRequest, cancellationToken); if (validationResult.IsValid) { var responseModel = await employeeRepository.SearchEmployeeByIdAsync(queryRequest); switch (responseModel is not null) { case true: return(new HandlerResultEntity <SearchEmployeeByIdQueryResponse>(true, string.Empty, responseModel)); case false: return(new HandlerResultEntity <SearchEmployeeByIdQueryResponse>(false, "employee id doenst exists", null)); } } else { return(new HandlerResultEntity <SearchEmployeeByIdQueryResponse>(false, ValidationResultErrorMessage.Format(validationResult), null)); } }