Exemple #1
0
        public void ChangeProductQuantity(int productId, int quantity)
        {
            if (productId < 0)
            {
                throw new MyMessageException("没有指定ProductID");
            }

            BllFactory.GetProductBLL().ChangeProductQuantity(productId, quantity);
        }
Exemple #2
0
        public object List(ProductSearchInfo pagingInfo)
        {
            pagingInfo.CheckPagingInfoState();

            List <Product> List   = BllFactory.GetProductBLL().SearchProduct(pagingInfo);
            var            result = new GridResult <Product>(List, pagingInfo.TotalRecords);

            return(new JsonResult(result));
        }
Exemple #3
0
        public object GetById(int id)
        {
            Product product = BllFactory.GetProductBLL().GetProductById(id);

            if (product == null)
            {
                throw new MyMessageException("指定的ID值无效。不能找到对应的记录。");
            }

            return(new JsonResult(product));
        }
Exemple #4
0
        public object Delete(int id, string returnUrl)
        {
            BllFactory.GetProductBLL().Delete(id);

            if (string.IsNullOrEmpty(returnUrl))
            {
                return(null);
            }
            else
            {
                return(new RedirectResult(returnUrl));
            }
        }
Exemple #5
0
        public object Show(int id)
        {
            Product product = BllFactory.GetProductBLL().GetProductById(id);

            if (product == null)
            {
                throw new MyMessageException("指定的ID值无效。不能找到对应的记录。");
            }

            List <Category>  categories = BllFactory.GetCategoryBLL().GetList();
            ProductInfoModel data       = new ProductInfoModel(categories, product);

            return(new PageResult("/Pages/Style1/Controls/ProductInfo.cshtml", data));
        }
        public object LoadModel(int?categoryId, int?page)
        {
            string papeUrl = this.GetTargetPageUrl("Products.aspx");

            if (this.IsStyle2)
            {
                // Style2 风格下,页面不需要绑定数据。数据由JS通过AJAX方式获取
                return(new PageResult(papeUrl, null));
            }


            ProductsPageModel result = new ProductsPageModel();

            result.Categories = BllFactory.GetCategoryBLL().GetList();

            if (result.Categories.Count == 0)
            {
                return(new RedirectResult("/Pages/Categories.aspx"));
            }

            // 获取当前用户选择的商品分类ID
            ProductSearchInfo info = new ProductSearchInfo();

            info.CategoryId = categoryId.HasValue ? categoryId.Value : 0;
            if (info.CategoryId == 0)
            {
                info.CategoryId = result.Categories[0].CategoryID;
            }
            info.PageIndex = page.HasValue ? page.Value - 1 : 0;
            info.PageSize  = AppHelper.DefaultPageSize;


            result.ProductInfo = new ProductInfoModel(
                result.Categories, new Product {
                CategoryID = info.CategoryId
            });
            result.PagingInfo             = info;
            result.CurrentCategoryId      = info.CategoryId;
            result.RequestUrlEncodeRawUrl = HttpUtility.UrlEncode(this.HttpContext.Request.RawUrl);


            // 加载商品列表
            result.Products = BllFactory.GetProductBLL().SearchProduct(info);

            return(new PageResult(papeUrl, result));
        }
Exemple #7
0
        public object ShowProductPicker(int?categoryId, string searchWord, int?page)
        {
            ProductSearchInfo info = new ProductSearchInfo();

            info.CategoryId = categoryId.HasValue ? categoryId.Value : 0;
            info.SearchWord = searchWord ?? string.Empty;
            info.PageIndex  = page.HasValue ? page.Value - 1 : 0;
            info.PageSize   = AppHelper.DefaultPageSize;


            ProductPickerModel data = new ProductPickerModel();

            data.SearchInfo   = info;
            data.List         = BllFactory.GetProductBLL().SearchProduct(info);
            data.CategoryList = BllFactory.GetCategoryBLL().GetList();

            return(new PageResult("/Pages/Style1/Controls/ProductPicker.cshtml", data));
        }
Exemple #8
0
        public void Update(Product product)
        {
            product.EnsureItemIsOK();

            BllFactory.GetProductBLL().Update(product);
        }
Exemple #9
0
        public void Insert(Product product)
        {
            product.EnsureItemIsOK();

            BllFactory.GetProductBLL().Insert(product);
        }