예제 #1
0
        private JObject GetCategory(EqtCategory cate)
        {
            var json = new JObject();

            json["id"]   = cate.Id;
            json["name"] = cate.Name;
            return(json);
        }
예제 #2
0
        private ComboTreeModel GetTree(EqtCategory parent, IEnumerable <EqtCategory> items)
        {
            var tree = new ComboTreeModel
            {
                id       = parent.Id,
                text     = parent.Name,
                children = items.Where(t => t.Pid == parent.Id).Select(t => GetTree(t, items)).ToArray()
            };

            return(tree);
        }
예제 #3
0
        public bool Modify(EqtCategory cate, Expression <Func <EqtCategory, bool> > predicate)
        {
            var count =
                Handler.ModifyAny(
                    m =>
            {
                m.Code     = cate.Code;
                m.HitCount = cate.HitCount;
                m.Name     = cate.Name;
                m.Pid      = cate.Pid;

                return(m);
            }, predicate, true).Count();

            return(0 < count);
        }
예제 #4
0
        public JsonResult FormSubmit(string id, string name, string code, short hits, string parentId)
        {
            var module = new EqtTypeModule(CurrentUser);
            var cate   = new EqtCategory
            {
                Code     = code,
                HitCount = hits,
                Name     = name,
                Pid      = parentId
            };
            var data = false;

            if (string.IsNullOrWhiteSpace(id))
            {
                data = module.Add(cate);
            }
            else
            {
                cate.Id = id;
                data    = module.Modify(cate, t => t.Id == id);
            }
            return(Json(new { code = 0, msg = "Ok", data = data }, "text/html"));
        }
예제 #5
0
 public bool Add(EqtCategory cate)
 {
     return
         (null != Handler.Add(cate, true));
 }