Exemple #1
0
 public PattrInfo Save()
 {
     if (this.Id != null)
     {
         Pattr.Update(this);
         return(this);
     }
     return(Pattr.Insert(this));
 }
Exemple #2
0
        public APIReturn _Add([FromForm] uint?Category_id, [FromForm] uint?Parent_id, [FromForm] bool?Is_filter, [FromForm] string Name)
        {
            PattrInfo item = new PattrInfo();

            item.Category_id = Category_id;
            item.Parent_id   = Parent_id;
            item.Is_filter   = Is_filter;
            item.Name        = Name;
            item             = Pattr.Insert(item);
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Exemple #3
0
        public ActionResult Edit([FromQuery] uint Id)
        {
            PattrInfo item = Pattr.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Exemple #4
0
        public APIReturn _Del([FromForm] uint[] ids)
        {
            int affrows = 0;

            foreach (uint id in ids)
            {
                affrows += Pattr.Delete(id);
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"删除成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Exemple #5
0
        public APIReturn _Edit([FromQuery] uint Id, [FromForm] uint?Category_id, [FromForm] uint?Parent_id, [FromForm] bool?Is_filter, [FromForm] string Name)
        {
            PattrInfo item = Pattr.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Category_id = Category_id;
            item.Parent_id   = Parent_id;
            item.Is_filter   = Is_filter;
            item.Name        = Name;
            int affrows = Pattr.Update(item);

            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Exemple #6
0
 public PattrInfo AddPattr(uint?Parent_id, bool?Is_filter, string Name) => Pattr.Insert(new PattrInfo {
     Category_id = this.Id,
     Parent_id   = Parent_id,
     Is_filter   = Is_filter,
     Name        = Name
 });