Example #1
0
        public static void DeleteProduct(int productID)
        {
            EditableProduct product = GetEditableProduct(productID);

            if (product != null)
            {
                GetEditableProducts().Remove(product);
            }
        }
        public ActionResult EditingEdit(int productID)
        {
            EditableProduct editProduct = NorthwindDataProvider.GetEditableProduct(productID);

            if (editProduct == null)
            {
                editProduct           = new EditableProduct();
                editProduct.ProductID = -1;
            }
            return(DemoView("Editing", "EditingForm", editProduct));
        }
Example #3
0
        public static void InsertProduct(EditableProduct product)
        {
            EditableProduct editProduct = new EditableProduct();

            editProduct.ProductID       = GetNewEditableProductID();
            editProduct.ProductName     = product.ProductName;
            editProduct.CategoryID      = product.CategoryID;
            editProduct.QuantityPerUnit = product.QuantityPerUnit;
            editProduct.UnitPrice       = product.UnitPrice;
            editProduct.UnitsInStock    = product.UnitsInStock;
            editProduct.Discontinued    = product.Discontinued;
            GetEditableProducts().Add(editProduct);
        }
Example #4
0
        public static void UpdateProduct(EditableProduct product)
        {
            EditableProduct editProduct = GetEditableProduct(product.ProductID);

            if (editProduct != null)
            {
                editProduct.ProductName     = product.ProductName;
                editProduct.CategoryID      = product.CategoryID;
                editProduct.QuantityPerUnit = product.QuantityPerUnit;
                editProduct.UnitPrice       = product.UnitPrice;
                editProduct.UnitsInStock    = product.UnitsInStock;
                editProduct.Discontinued    = product.Discontinued;
            }
        }
        public ActionResult EditingEdit(EditableProduct product)
        {
            if (!ModelState.IsValid)
            {
                return(DemoView("Editing", "EditingForm", product));
            }

            if (product.ProductID == -1)
            {
                NorthwindDataProvider.InsertProduct(product);
            }
            else
            {
                NorthwindDataProvider.UpdateProduct(product);
            }
            return(RedirectToAction("Editing"));
        }
Example #6
0
 public ActionResult InlineEditingAddNewPartial(EditableProduct product)
 {
     if (ModelState.IsValid)
     {
         try {
             NorthwindDataProvider.InsertProduct(product);
         }
         catch (Exception e) {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("InlineEditingPartial", NorthwindDataProvider.GetEditableProducts()));
 }
Example #7
0
 public static void UpdateProduct(EditableProduct product) {
     EditableProduct editProduct = GetEditableProduct(product.ProductID);
     if(editProduct != null) {
         editProduct.ProductName = product.ProductName;
         editProduct.CategoryID = product.CategoryID;
         editProduct.QuantityPerUnit = product.QuantityPerUnit;
         editProduct.UnitPrice = product.UnitPrice;
         editProduct.UnitsInStock = product.UnitsInStock;
         editProduct.Discontinued = product.Discontinued;
     }
 }
Example #8
0
 public static void InsertProduct(EditableProduct product) {
     EditableProduct editProduct = new EditableProduct();
     editProduct.ProductID = GetNewEditableProductID();
     editProduct.ProductName = product.ProductName;
     editProduct.CategoryID = product.CategoryID;
     editProduct.QuantityPerUnit = product.QuantityPerUnit;
     editProduct.UnitPrice = product.UnitPrice;
     editProduct.UnitsInStock = product.UnitsInStock;
     editProduct.Discontinued = product.Discontinued;
     GetEditableProducts().Add(editProduct);
 }