public ActionResult <GetBrandResponse> GetBrand(long id) { var getBrandRequest = new GetBrandRequest(); getBrandRequest.Id = id; return(brandService.GetBrand(getBrandRequest)); }
public async stt::Task GetBrandRequestObjectAsync() { moq::Mock <IdentityAwareProxyOAuthService.IdentityAwareProxyOAuthServiceClient> mockGrpcClient = new moq::Mock <IdentityAwareProxyOAuthService.IdentityAwareProxyOAuthServiceClient>(moq::MockBehavior.Strict); GetBrandRequest request = new GetBrandRequest { Name = "name1c9368b0", }; Brand expectedResponse = new Brand { Name = "name1c9368b0", SupportEmail = "support_email60b1be92", ApplicationTitle = "application_title59ccbd06", OrgInternalOnly = false, }; mockGrpcClient.Setup(x => x.GetBrandAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Brand>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IdentityAwareProxyOAuthServiceClient client = new IdentityAwareProxyOAuthServiceClientImpl(mockGrpcClient.Object, null); Brand responseCallSettings = await client.GetBrandAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Brand responseCancellationToken = await client.GetBrandAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public GetBrandResponse GetBrand(GetBrandRequest getBrandRequest) { var brand = brandRepository.FindBrandById(getBrandRequest.Id); var brandDTO = messageMapper.MapToBrandDto(brand); return(new GetBrandResponse { Brand = brandDTO }); }
public ActionResult <GetBrandResponse> GetBrand(long id) { var request = new GetBrandRequest { Id = id }; var response = _service.GetBrand(request); return(response); }
/// <summary>Snippet for GetBrand</summary> public void GetBrandRequestObject() { // Snippet: GetBrand(GetBrandRequest, CallSettings) // Create client IdentityAwareProxyOAuthServiceClient identityAwareProxyOAuthServiceClient = IdentityAwareProxyOAuthServiceClient.Create(); // Initialize request argument(s) GetBrandRequest request = new GetBrandRequest { Name = "", }; // Make the request Brand response = identityAwareProxyOAuthServiceClient.GetBrand(request); // End snippet }
public GetBrandResponse GetBrand(GetBrandRequest getBrandRequest) { GetBrandResponse getBrandResponse = null; if (getBrandRequest.Id > 0) { var brand = _brandRepository.FindBrandById(getBrandRequest.Id); var brandDto = _messageMapper.MapToBrandDto(brand); getBrandResponse = new GetBrandResponse { Brand = brandDto }; } return(getBrandResponse); }
/// <summary>Snippet for GetBrandAsync</summary> public async Task GetBrandRequestObjectAsync() { // Snippet: GetBrandAsync(GetBrandRequest, CallSettings) // Additional: GetBrandAsync(GetBrandRequest, CancellationToken) // Create client IdentityAwareProxyOAuthServiceClient identityAwareProxyOAuthServiceClient = await IdentityAwareProxyOAuthServiceClient.CreateAsync(); // Initialize request argument(s) GetBrandRequest request = new GetBrandRequest { Name = "", }; // Make the request Brand response = await identityAwareProxyOAuthServiceClient.GetBrandAsync(request); // End snippet }
public GetBrandResponse GetBrand(GetBrandRequest request) { var response = new GetBrandResponse(); WithErrorHandling(() => { var brand = _brandRepository.FindBrandById(request.Id); var brandDto = brand.MapToBrandDto(); response.Brand = brandDto; response.Messages.Add("Successfully get the brand"); response.StatusCode = HttpStatusCode.OK; }, response); return(response); }
public void GetBrandRequestObject() { moq::Mock <IdentityAwareProxyOAuthService.IdentityAwareProxyOAuthServiceClient> mockGrpcClient = new moq::Mock <IdentityAwareProxyOAuthService.IdentityAwareProxyOAuthServiceClient>(moq::MockBehavior.Strict); GetBrandRequest request = new GetBrandRequest { Name = "name1c9368b0", }; Brand expectedResponse = new Brand { Name = "name1c9368b0", SupportEmail = "support_email60b1be92", ApplicationTitle = "application_title59ccbd06", OrgInternalOnly = false, }; mockGrpcClient.Setup(x => x.GetBrand(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IdentityAwareProxyOAuthServiceClient client = new IdentityAwareProxyOAuthServiceClientImpl(mockGrpcClient.Object, null); Brand response = client.GetBrand(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }