Example #1
0
        public ActionResult GetAllProducts()
        {
            ProductModel objModel = new ProductModel();

            try
            {
                APIRepository objAPI = new APIRepository();
                _log.Info("Calling API for getting the Product details");
                HttpResponseMessage responseResult = objAPI.GetResponse("api/v1/products");

                objModel.ProductList = responseResult.Content.ReadAsAsync <List <ProductModel> >().Result;

                ViewBag.Title = "All Products";
                _log.Info("Getting all product details");
            }
            catch (Exception ex)
            {
                _log.Error("An error occurred in GetAllProducts GET Method: " + ex.Message);
                _log.LogException(ex, "GetAllProducts", "Product");
            }

            return(View(objModel));
        }