public virtual JsonResult GetProduct(ViewModels.Orders.ProductsViewModel product, int pageIndex, int pageSize)
        {
            if (pageIndex < 0)
            {
                pageIndex = 0;
            }

            int rowNumber = pageIndex * pageSize;

            var listProductQuery =
                db.Products
                .AsQueryable()
            ;

            if (product.Name != null)
            {
                listProductQuery =
                    listProductQuery
                    .Where(current => current.Name.Contains(product.Name))
                ;
            }

            if (product.Price != null)
            {
                listProductQuery =
                    listProductQuery
                    .Where(current => current.Price == product.Price.Value)
                ;
            }

            int Count = listProductQuery.Count();

            listProductQuery =
                listProductQuery
                .OrderBy(current => current.Name)
                .Skip(pageIndex * pageSize)
                .Take(pageSize);

            var listProduct = listProductQuery.ToList();

            List <ProductsViewModel> listProductViewModel = new List <ProductsViewModel>();

            foreach (var item in listProduct)
            {
                ProductsViewModel objProductsViewModel = new ProductsViewModel();

                objProductsViewModel.Id          = item.Id;
                objProductsViewModel.Name        = item.Name;
                objProductsViewModel.Price       = item.Price;
                objProductsViewModel.Description = item.Description;
                objProductsViewModel.RowNumber   = ++rowNumber;

                listProductViewModel.Add(objProductsViewModel);
            }

            var result = new { data = listProductViewModel, count = Count };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public virtual JsonResult Edit(ViewModels.Orders.ProductsViewModel product)
        {
            bool updated = false;

            try
            {
                var rowEdit = db.Products.Where(C => C.Id == product.Id).FirstOrDefault();
                rowEdit.GroupProductId = product.GroupProductId;
                rowEdit.Available      = product.Available;
                rowEdit.Name           = product.Name;
                rowEdit.Description    = product.Description;
                rowEdit.Price          = product.Price.Value;
                db.SaveChanges();
                updated = true;
            }
            catch (Exception)
            {
            }
            return(Json(updated));
        }