// A utility function that facilitates the call to the helper to update an Invoice in the database.
        private bool updateInvoice(Invoice invoice)
        {
            // Send the post request.
            HttpResponseMessage response = helper.doPostRequest(getUrl("Update", invoice.invoiceId), invoice);

            return(response.IsSuccessStatusCode);
        }
Ejemplo n.º 2
0
        public ActionResult Create(Product product)
        {
            HttpResponseMessage response = helper.doPostRequest(getUrl("Create"), product);

            if (!response.IsSuccessStatusCode)
            {
                ViewBag.errorMessage = "Unable to add product.";
                return(View());
            }

            ProductDto productDto = helper.getFromResponse <ProductDto>(response);

            return(RedirectToAction("Details", new {
                id = productDto.productId
            }));
        }