/// <summary>
        /// 品牌分类关联添加
        /// zhoub 20150709
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultModel AddBrand_Category(Brand_CategoryModel model)
        {
            ResultModel result         = new ResultModel();
            var         brand_Category = base._database.Db.Brand_Category.Find(base._database.Db.Brand_Category.BrandID == model.BrandID && base._database.Db.Brand_Category.CategoryId == model.CategoryId);

            if (brand_Category == null)
            {
                result.IsValid = true;
                result.Data    = base._database.Db.Brand_Category.Insert(model);
            }
            else
            {
                result.IsValid = false;
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 添加品牌关联保存
        /// zhoub 20150709
        /// </summary>
        /// <returns></returns>
        public JsonResult AddBrand_Category(int?brandID, int?categoryId)
        {
            Brand_CategoryModel model       = new Brand_CategoryModel();
            ResultModel         resultModel = new ResultModel();

            if (brandID.HasValue && categoryId.HasValue)
            {
                model.Brand_CategoryId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                model.BrandID          = (int)brandID;
                model.CategoryId       = (int)categoryId;
                model.AddUser          = UserInfo.CurrentUserName;
                model.AddDate          = DateTime.Now;
                model.IsEnable         = true;
                var result = this._brand_CategoryService.AddBrand_Category(model);
                if (result.IsValid)
                {
                    //添加品牌关联成功
                    resultModel.Messages = new List <string>()
                    {
                        "Add brand association success"
                    };
                }
                else
                {
                    //该品牌关联已经存在.
                    resultModel.Messages = new List <string>()
                    {
                        "The brand association already exists."
                    };
                }
            }
            else
            {
                resultModel.IsValid  = false;
                resultModel.Messages = new List <string>()
                {
                    "Key ID error"
                };
            }
            string opera = string.Format("品牌关联添加:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);

            LogPackage.InserAC_OperateLog(opera, "Product--Brands-Add");
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }