Beispiel #1
0
        public ActionResult CUD(Products newProduct,
                                string CreateBtn, string UpdateBtn, string DeleteBtn)
        {
            Products Producto;
            //var Proxy = new Proxy();
            var          Proxy  = new BLL.Product();
            ActionResult Result = View();

            if (CreateBtn != null)
            {
                Producto = Proxy.Create(newProduct);
                if (Producto != null)
                {
                    Result = RedirectToAction("CUD", new { id = Producto.ProductID });
                }
            }
            else if (UpdateBtn != null) //modificacion de producto
            {
                var IsUpdate = Proxy.Update(newProduct);
                if (IsUpdate)
                {
                    Result = Content("El producto se ha actualizado");
                }
            }
            else if (DeleteBtn != null) //eliminar producto
            {
                var DeletedProduct = Proxy.Delete(newProduct.ProductID);
                if (DeletedProduct)
                {
                    Result = Content("El producto se ha eliminado");
                }
            }
            return(Result);
        }