예제 #1
0
 /// <summary>
 /// 创建新的 T_Categories 对象。
 /// </summary>
 /// <param name="id">id 属性的初始值。</param>
 /// <param name="name">name 属性的初始值。</param>
 /// <param name="parentid">parentid 属性的初始值。</param>
 public static T_Categories CreateT_Categories(global::System.Int32 id, global::System.String name, global::System.Int32 parentid)
 {
     T_Categories t_Categories = new T_Categories();
     t_Categories.id = id;
     t_Categories.name = name;
     t_Categories.parentid = parentid;
     return t_Categories;
 }
예제 #2
0
        public ActionResult Add(T_Categories cate)
        {
            var msg = new Message();
            var currentUser = UserService.GetModal(a => a.username.Equals(User.Identity.Name));

            //用户为空
            if (cate == null)
            {
                msg.code = 0;
                msg.body = "请确认信息的完整性";
            }
            else if (cate.name.Length > 120)
            {
                msg.code = 0;
                msg.body = "分类名的长度不能大于120";
            }
            else if (CheckCateIsExits(cate.name))
            {
                msg.code = 0;
                msg.body = "该分类已存在";
            }
            else if (cate.id.Equals(cate.parentid))
            {
                msg.code = 0;
                msg.body = "上级分类不能是自己";
            }
            else if (currentUser.type == 0)
            {
                msg.code = 0;
                msg.body = "您的权限不足";
            }
            else
            {
                var bll = CategoryService;

                cate.createtime = DateTime.Now;
                cate.uid = currentUser.id;

                var result = bll.Insert(cate);

                if (result)
                {
                    msg.code = 1;
                    msg.body = "添加成功";
                }
                else
                {
                    msg.code = 0;
                    msg.body = "添加失败,请联系管理员";
                }
            }

            return Json(msg);
        }
예제 #3
0
 /// <summary>
 /// 用于向 T_Categories EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToT_Categories(T_Categories t_Categories)
 {
     base.AddObject("T_Categories", t_Categories);
 }