Ejemplo n.º 1
0
        public async Task CreateRestaurantCategories(AddRestaurantCategoryViewModel data)
        {
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);
                var httpContent         = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
                HttpResponseMessage msg = await client.PostAsync("restaurants/categories/create", httpContent);

                msg.EnsureSuccessStatusCode();
            }
        }
        public async Task <IActionResult> AddRestaurantCategory(AddRestaurantCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // save
                    await restaurantApi.CreateRestaurantCategories(model);

                    return(RedirectToAction("GetAllRestaurantCategories"));
                }
                catch (Exception ex)
                {
                    ViewBag.Error = "Failed to Edit a Area";
                    return(RedirectToAction("AddRestaurantCategory"));
                }
            }
            return(View(model));
        }