Example #1
0
        public async Task CreateFoodRequestAsync(FoodItemRequest foodItems)
        {
            GrpcChannel channel = GrpcChannel.ForAddress("http://*****:*****@response}", response);
        }
Example #2
0
        public async Task <IActionResult> PostFoodGrpc([FromBody] FoodItemRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            await _service.CreateGrpcFoodRequestAsync(request);

            return(Accepted());
        }
Example #3
0
        public async Task CreateFoodItems(FoodItemRequest foodItemRequest)
        {
            var restaurantList = await GetRestaurants();

            if (restaurantList == null || restaurantList.Count < 1)
            {
                throw new ArgumentNullException();
            }

            var restaurant = restaurantList.Find(a => a.Name == foodItemRequest.RestaurantName);

            if (restaurant == null)
            {
                throw new ArgumentNullException("Restaurant has to be an existing Restaurant");
            }

            var foodContent = new StringContent(JsonConvert.SerializeObject(foodItemRequest), System.Text.Encoding.UTF8, "application/json");

            var responseString = await _httpClient.PostAsync($"{_foodUrl}/food", foodContent);
        }
Example #4
0
        public async Task CreateGrpcFoodRequestAsync(FoodItemRequest foodItems)
        {
            _logger.LogInformation("grpc client created");

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);

            GrpcChannel channel = GrpcChannel.ForAddress("https://*****:*****@response}", response);
        }
Example #5
0
 public async Task AddFoodItemAsync(FoodItemRequest foodItem)
 {
     //TODO: Add tests
     await _mediator.Send(foodItem);
 }