public List <Models.ProductDataSqlModel> DataList(int verId) { var query = ProductPublishSqlRepository.GetQuery(o => o.PublishId == verId); var queryVer = ProductPublishVerRepository.GetQuery(o => o.PublishId == verId); var queryMenu = ProductMenuLimitRepository.GetQuery(); var q = from x in query join y in queryVer on x.PublishId equals y.PublishId orderby x.RunSort select new Models.ProductDataSqlModel() { Id = x.Id, MenuId = x.MenuId, RunSort = x.RunSort, RunSql = x.RunSql, Index = x.PublishId, Title = queryMenu.Where(o => o.ModuleId == y.MenuModuleId && o.MenuId == x.MenuId).Select(o => o.Title).FirstOrDefault() }; var ms = q.ToList(); var menus = new List <Models.ProductDataSqlModel>(); int i = 0; foreach (var m in ms) { m.DataId = m.Index.ToString(); m.SqlMore = m.RunSql.TrimMore(200); m.Count = ms.Count; m.Index = i; i++; menus.Add(m); } return(menus); }
public void MoveItem(short mode, int sn, int verId) { var list = ProductPublishSqlRepository.GetQuery(o => o.PublishId == verId).OrderBy(o => o.RunSort).ToList(); var obj = list.FirstOrDefault(o => o.MenuId == sn); switch (mode) { case 2: //下移 var obj1 = list.LastOrDefault(); if (obj.Id != obj1.Id) { Entity.ProductPublishSql next = null; for (var i = 0; i < list.Count; i++) { if (obj.Id == list[i].Id) { next = list[i + 1]; break; } } if (next != null) { var sort = obj.RunSort; obj.RunSort = next.RunSort; next.RunSort = sort; ProductPublishSqlRepository.SaveChanges(); } } break; default: //上移 var obj2 = list.FirstOrDefault(); if (obj.Id != obj2.Id) { Entity.ProductPublishSql prev = null; for (var i = 0; i < list.Count; i++) { if (obj.Id == list[i].Id) { prev = list[i - 1]; break; } } if (prev != null) { var sort = obj.RunSort; obj.RunSort = prev.RunSort; prev.RunSort = sort; ProductPublishSqlRepository.SaveChanges(); } } break; } }