Exemplo n.º 1
0
        public async Task MenuOrder(Menus entity, SqlConnection con, IDbTransaction transaction)
        {
            var menus = await _dapperManager.QueryAsyncTrans <Menus>("SELECT * FROM Menus WHERE ParentMenuId=@ParentMenuId", new { entity.ParentMenuId }, transaction, con);

            if (menus.Select(a => a.MenuOrder).Contains(entity.MenuOrder))
            {
                foreach (var m in menus.Where(a => a.MenuOrder >= entity.MenuOrder && a.MenuId != entity.MenuId).OrderBy(a => a.MenuOrder))
                {
                    m.MenuOrder = m.MenuOrder + 1;
                    _menusRepo.Update(m, transaction, con);
                }
            }
        }