public static void Delete(EditableProduct product)
 {
     EditableProduct target = One(p => p.ProductID == product.ProductID);
     if (target != null)
     {
         All().Remove(target);
     }
 }
        public static void Delete(EditableProduct product)
        {
            EditableProduct target = One(p => p.ProductID == product.ProductID);

            if (target != null)
            {
                All().Remove(target);
            }
        }
 public ActionResult EditTemplate(EditableProduct product)
 {
     if (product.ProductID == 0)
     {
         product.ProductID = 1;
         product.ProductName = "Chai";
         product.UnitsInStock = 39;
         product.UnitPrice =  18.00m;
         product.LastSupply = DateTime.Today;
     }
     return View(product);
 }
 public static void Update(EditableProduct product)
 {
     EditableProduct target = One(p => p.ProductID == product.ProductID);
     if (target != null)
     {
         target.ProductName = product.ProductName;
         target.UnitPrice = product.UnitPrice;
         target.UnitsInStock = product.UnitsInStock;
         target.Discontinued = product.Discontinued;
         target.LastSupply = product.LastSupply;
     }
 }
        public static void Update(EditableProduct product)
        {
            EditableProduct target = One(p => p.ProductID == product.ProductID);

            if (target != null)
            {
                target.ProductName  = product.ProductName;
                target.UnitPrice    = product.UnitPrice;
                target.UnitsInStock = product.UnitsInStock;
                target.Discontinued = product.Discontinued;
                target.LastSupply   = product.LastSupply;
            }
        }
Ejemplo n.º 6
0
        [WebMethod(EnableSession = true)] //Session required by SessionCustomerRepository
        public GridModel Delete(EditableProduct value, GridState state)
        {
            SessionProductRepository.Delete(value);

            return(SessionProductRepository.All().AsQueryable().ToGridModel(state));
        }
Ejemplo n.º 7
0
        public GridModel Update(GridState state, EditableProduct value)
        {
            SessionProductRepository.Update(value);

            return SessionProductRepository.All().AsQueryable().ToGridModel(state);
        }
Ejemplo n.º 8
0
        public GridModel Insert(GridState state, EditableProduct value)
        {
            SessionProductRepository.Insert(value);

            return(SessionProductRepository.All().AsQueryable().ToGridModel(state));
        }
Ejemplo n.º 9
0
        public GridModel Insert(EditableProduct value, GridState state)
        {
            SessionProductRepository.Insert(value);

            return SessionProductRepository.All().AsQueryable().ToGridModel(state);
        }
        public static void Insert(EditableProduct product)
        {
            product.ProductID = All().OrderByDescending(p => p.ProductID).First().ProductID + 1;

            All().Insert(0, product);
        }
        public ActionResult ColumnSettings_Save(int id)
        {
            //Create a new instance of the EditableProduct class and set its ProductID property.
            EditableProduct product = new EditableProduct
            {
                ProductID = id
            };

            //Perform model binding (fill the product properties and validate it).
            if (TryUpdateModel(product))
            {
                //The model is valid - update the product and redisplay the grid.
                SessionProductRepository.Update(product);

                //GridRouteValues() is an extension method which returns the
                //route values defining the grid state - current page, sort expression, filter etc.
                RouteValueDictionary routeValues = this.GridRouteValues();

                return RedirectToAction("ColumnSettings", routeValues);
            }

            //The model is invalid - render the current view to show any validation errors
            return View("ColumnSettings", SessionProductRepository.All());
        }
        public static void Insert(EditableProduct product)
        {
            product.ProductID = All().OrderByDescending(p => p.ProductID).First().ProductID + 1;

            All().Insert(0, product);
        }