Example #1
0
        public SingleApiResponse ChangeSort(MenuChangeSortRequest req)
        {
            var result = MenuRepo.ChangeSort(req);

            return(result ? new SingleApiResponse()
            {
                Data = "移动成功"
            } : new SingleApiResponse()
            {
                ErrMsg = "移动失败"
            });
        }
Example #2
0
        public bool ChangeSort(MenuChangeSortRequest req)
        {
            var menu  = RepoBase.Instance.GetWhere <SS_MENU>(x => x.M_ID == req.M_ID.Value).FirstOrDefault();
            var menus = RepoBase.Instance.GetWhere <SS_MENU>(x => x.M_PARENTID == menu.M_PARENTID);

            if (req.ActionType.Value == 1)
            {
                var minOrderId = menus.Min(x => x.M_ORDERID);
                //如果已经是最上面的
                if (menu.M_ORDERID == minOrderId)
                {
                    return(false);
                }

                //和最上面的交换
                var preMenu = menus.Where(x => x.M_ORDERID < menu.M_ORDERID).OrderByDescending(x => x.M_ORDERID).First();
                var temp    = preMenu.M_ORDERID;
                preMenu.M_ORDERID = menu.M_ORDERID;
                menu.M_ORDERID    = temp;
                RepoBase.Instance.Update(preMenu);
            }
            else
            {
                var maxOrderId = menus.Max(x => x.M_ORDERID);
                //如果已经是最下面的
                if (menu.M_ORDERID == maxOrderId)
                {
                    return(false);
                }

                //和最下面的交换
                var nextMenu = menus.Where(x => x.M_ORDERID > menu.M_ORDERID).OrderBy(x => x.M_ORDERID).First();
                var temp     = nextMenu.M_ORDERID;
                nextMenu.M_ORDERID = menu.M_ORDERID;
                menu.M_ORDERID     = temp;
                RepoBase.Instance.Update(nextMenu);
            }

            RepoBase.Instance.Update(menu);
            return(true);
            //var client = DBProxy.CreateClient();
            //var param = new DynamicParameters();
            //param.Add("@id", req.M_ID.Value);
            //param.Add("@sortType", req.ActionType.Value);
            //param.Add("@result", 0, DbType.Int32, ParameterDirection.Output);
            //var resExecute = client.Execute("sp_change_S_Menu_Sort", param, null, null, CommandType.StoredProcedure);  //0
            //return Convert.ToInt32(param.Get<object>("@result"));
        }
Example #3
0
 public SingleApiResponse ChangeSort([FromBody] MenuChangeSortRequest req)
 {
     return(MenuBiz.ChangeSort(req));
 }