Example #1
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public ResultSet Add(ProductType entity)
        {
            Func <ProductType, ResultStatus> validate = (_entity) =>
            {
                return(new ResultStatus());
            };

            Func <ProductType, ResultStatus> op = (_entity) =>
            {
                int ret = new ProductTypeDal().Add(entity);
                if (ret > 0)
                {
                    return(new ResultStatus());
                }
                else
                {
                    return new ResultStatus()
                           {
                               Success     = false,
                               Code        = StatusCollection.AddFailed.Code,
                               Description = StatusCollection.AddFailed.Description
                           }
                };
            };

            return(HandleBusiness(entity, op, validate));
        }
Example #2
0
        /// <summary>
        /// 商品分类
        /// </summary>
        /// <returns></returns>
        public ActionResult Catalog()
        {
            var model = new CatalogViewModel();
            var dal   = new BrandDal();

            model.BrandList = dal.GetList();
            var pdal = new ProductTypeDal();

            model.ProductTypeList = pdal.GetTypeFList();
            return(PartialView(model));
        }
Example #3
0
        /// <summary>
        /// 导航
        /// </summary>
        /// <returns></returns>
        public ActionResult Navigation()
        {
            var model = new NavViewModel();
            var dal   = new BrandDal();

            model.BrandTypeList = dal.GetListByProduct();
            model.BrandList     = dal.GetList();
            var pdal = new ProductTypeDal();

            model.ProductTypeList = pdal.GetTypeFList();
            return(PartialView(model));
        }
Example #4
0
        /// <summary>
        /// 获取所有
        /// </summary>
        public ResultSet <Page <ProductType> > GetAll(string fields, int pageIndex, int pageSize, string where, object param, string orderBy)
        {
            Func <string, int, int, string, object, string, ResultStatus> validate = (_fields, _pageIndex, _pageSize, _where, _param, _orderBy) =>
            {
                if (_pageIndex <= 0)
                {
                    return new ResultStatus()
                           {
                               Code        = StatusCollection.ParameterError.Code,
                               Description = "参数 pageIndex 必须大于0",
                               Success     = false
                           }
                }
                ;

                if (_pageSize <= 0 || _pageSize > 100)
                {
                    return new ResultStatus()
                           {
                               Code        = StatusCollection.ParameterError.Code,
                               Description = "参数 pageSize 必须大于0,且小于等于100",
                               Success     = false
                           }
                }
                ;

                return(new ResultStatus());
            };

            Func <string, int, int, string, object, string, Page <ProductType> > op = (_fields, _pageIndex, _pageSize, _where, _param, _orderBy) =>
            {
                int recordCount = 0;

                IList <ProductType> list = new ProductTypeDal().GetAll(_fields, _pageIndex, _pageSize, _where, _param, _orderBy, out recordCount);
                return(new Page <ProductType>(_pageIndex, _pageSize, recordCount, list));
            };

            return(HandleBusiness(fields, pageIndex, pageSize, where, param, orderBy, op, validate));
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductTypeLogic"/> class.
 /// </summary>
 public ProductTypeLogic()
 {
     this.dal = new ProductTypeDal();
 }
Example #6
0
        /// <summary>
        /// 更新
        /// </summary>
        public ResultSet Update(string fields, object param, string where)
        {
            Func <string, object, string, ResultStatus> validate = (_fields, _param, _where) =>
            {
                if (String.IsNullOrEmpty(_fields))
                {
                    return new ResultStatus()
                           {
                               Code        = StatusCollection.ParameterError.Code,
                               Description = "参数 fields 不能为空",
                               Success     = false
                           }
                }
                ;

                if (_param == null)
                {
                    return new ResultStatus()
                           {
                               Code        = StatusCollection.ParameterError.Code,
                               Description = "参数 param 不能为空",
                               Success     = false
                           }
                }
                ;

                return(new ResultStatus());
            };

            Func <string, object, string, ResultStatus> op = (_fields, _param, _where) =>
            {
                int ret = new ProductTypeDal().Update(_fields, _param, _where);
                if (ret > 0)
                {
                    return(new ResultStatus());
                }
                else
                {
                    return new ResultStatus()
                           {
                               Success     = false,
                               Code        = StatusCollection.UpdateFailed.Code,
                               Description = StatusCollection.UpdateFailed.Description
                           }
                };
            };

            return(HandleBusiness(fields, param, where, op, validate));
        }

        #endregion

        #region Extend

        //  <summary>
        //  修改一条数据,参数为实体Entity, 需要先取得实体,更改实体属性后再操作
        // </summary>
        public bool Update2(ProductType entity)
        {
            return(new ProductTypeDal().Update2(entity));
        }
Example #7
0
        /// <summary>
        /// 根据ID 查询产品分类
        /// </summary>
        /// <param name="proTypeId"></param>
        /// <returns></returns>
        public static List <ProductType> GetProductType(int proTypeId)
        {
            string sql = "select * from ProductType where ProTypeId=" + proTypeId;

            return(ProductTypeDal.GetProductType(sql));
        }
Example #8
0
 /// <summary>
 /// 添加产品类型
 /// </summary>
 /// <param name="proType"></param>
 /// <returns></returns>
 public static int AddProductType(ProductType proType)
 {
     return(ProductTypeDal.AddProductType(proType));
 }