Exemple #1
0
        /// <summary>
        /// 话题类型列表
        /// </summary>
        /// <returns></returns>
        private List <SelectListItem> GetTopicTypeList(int placeId)
        {
            IPostBarTopicTypeBLL typeBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

            var typelist = typeBll.GetList(x => x.PropertyPlaceId == placeId);

            List <SelectListItem> itemList = new List <SelectListItem>();

            foreach (var item in typelist)
            {
                itemList.Add(new SelectListItem()
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }

            itemList.Add(new SelectListItem()
            {
                Text     = "话题分类",
                Value    = "0",
                Selected = true
            });

            return(itemList);
        }
Exemple #2
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));
        }
        public ApiPageResultModel GetTopicSortList([FromUri] TopicSortSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != model.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取小区所有主题分类列表
                    IPostBarTopicTypeBLL postBarTopicTypeBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

                    Expression <Func <T_PostBarTopicType, bool> > where = u => u.PropertyPlaceId == model.PropertyPlaceId;

                    var list = postBarTopicTypeBll.GetList(where, "Id", false).Select(s => new
                    {
                        ID   = s.Id,
                        Name = s.Name
                    }).ToList();

                    resultModel.result = list;
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemple #4
0
        public ContentResult CategoryCheckExist(string name, int categoryId = 0)
        {
            //获取当前小区
            int currentPlaceId = GetSessionModel().PropertyPlaceId.Value;

            //调用BLL层判断主题类别是否已存在
            IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

            //如果已存在,验证不通过
            if (categoryBll.Exist(m => m.Name == name && m.PropertyPlaceId == currentPlaceId && m.Id != categoryId))
            {
                return(Content("false"));
            }
            else//不存在,则验证通过
            {
                return(Content("true"));
            }
        }
Exemple #5
0
        public ActionResult CategoryList(SearchModel model)
        {
            //获取当前物业小区ID
            int currentPlaceId = GetSessionModel().PropertyPlaceId.Value;

            IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

            //初始化查询条件:当前小区
            Expression <Func <T_PostBarTopicType, bool> > where = c => c.PropertyPlaceId == currentPlaceId;
            //根据主题类别名称模糊查询
            if (!string.IsNullOrEmpty(model.Kword))
            {
                where = PredicateBuilder.And(where, a => a.Name.Contains(model.Kword));
            }

            //排序
            var sortModel = this.SettingSorting("id", false);
            //获取分页数据
            var data = categoryBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(data));
        }
Exemple #6
0
        public JsonResult DeleteCategory(int id)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //调用BLL层获取要删除的主题类别
                IPostBarTopicTypeBLL categoryBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

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

                if (category == null)
                {
                    jm.Msg = "该主题类别不存在";
                }
                else if (category.PostBarTopics.Count() > 0)
                {
                    jm.Msg = "已有该类别的主题,不能删除";
                }
                else
                {
                    //删除
                    if (categoryBll.Delete(category))
                    {
                        //记录日志
                        jm.Content = "删除沟通主题类别 " + category.Name;
                    }
                    else
                    {
                        jm.Msg = "删除失败";
                    }
                }
            }
            catch
            {
                jm.Msg = "删除失败";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemple #7
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));
        }
Exemple #8
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"));
            }
        }