Ejemplo n.º 1
0
        public JsonResult AddCategory(TopicTypeModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                //模型赋值
                T_PostBarTopicType category = new T_PostBarTopicType()
                {
                    Name            = model.CategoryName,
                    PropertyPlaceId = GetSessionModel().PropertyPlaceId.Value
                };
                //调用BLL层进行添加处理
                IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

                categoryBll.Save(category);
                //记录日志
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult EditCategory(TopicTypeModel model)
        {
            JsonModel jm = new JsonModel();

            if (ModelState.IsValid)
            {
                ///调用BLL层获取正在编辑的主题类别
                IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

                var category = categoryBll.GetEntity(c => c.Id == model.CategoryId);
                if (category != null)
                {
                    //重新赋值
                    category.Name = model.CategoryName;
                    //编辑:如果成功
                    if (categoryBll.Update(category))
                    {
                        //记录日志
                        jm.Content = PropertyUtils.ModelToJsonString(model);
                    }
                    else
                    {
                        jm.Msg = "编辑失败";
                    }
                }
                else
                {
                    jm.Msg = "该主题类别不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult EditCategory(int id)
        {
            JsonModel jm = new JsonModel();

            //调用BLL层获取要编辑的沟通主题类别
            IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

            var category = categoryBll.GetEntity(c => c.Id == id);

            if (category != null)
            {
                //给模型赋值,传递到编辑页面
                TopicTypeModel model = new TopicTypeModel()
                {
                    CategoryId   = category.Id,
                    CategoryName = category.Name
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("CategoryList"));
            }
        }