Пример #1
0
        public async Task <IActionResult> Index()
        {
            IEnumerable <ConferenceViewModel> model = new List <ConferenceViewModel>();
            var apiClient = await gatewayService.GetHttpClient();

            var response = await apiClient.GetAsync("conference");

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.StatusCode);
            }
            else
            {
                var content = await response.Content.ReadAsStringAsync();

                model = JsonConvert.DeserializeObject <IEnumerable <ConferenceViewModel> >(content);
            }
            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> Index()
        {
            var apiClient = await gatewayService.GetHttpClient();

            var reservation = new ReservationViewModel();
            var content     = JsonConvert.SerializeObject(reservation);
            var data        = new StringContent(content, Encoding.UTF8, "application/json");


            var response = await apiClient.PostAsync("reservation", data);

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.StatusCode);
            }
            else
            {
                var result = await response.Content.ReadAsStringAsync();

                //model = JsonConvert.DeserializeObject<IEnumerable<ConferenceViewModel>>(content);
            }

            return(View());
        }