Ejemplo n.º 1
0
 /// <summary>
 /// 自动生成排序编号
 /// </summary>
 private string MaxOrderNumber(Menu parent)
 {
     using (var dbContext = new AccountDbContext())
     {
         var orderNum = parent.Orderby;
         var count = dbContext.Menus.Where(o => o.ParentId == parent.ID).Count()+1;
         orderNum += count < 10 ? "0" + count.ToString() : count.ToString();
         return orderNum;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 编辑保存
 /// </summary>
 public void SaveMenu(Menu model)
 {
     string cachingKey = "ConfigFile_AdminMenuConfig";
     using (var dbContext = new AccountDbContext())
     {
         model.ParentId = model.ParentId ?? 0;
         if (model.ID > 0)
         {
             dbContext.Update<Menu>(model);
         }
         else
         {
             dbContext.Insert<Menu>(model);
         }
         Caching.Remove(cachingKey); //删除菜单缓存
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 编辑保存
 /// </summary>
 public void SaveMenu(Menu model)
 {
     string cachingKey = "ConfigFile_AdminMenuConfig";
     using (var dbContext = new AccountDbContext())
     {
         model.ParentId = model.ParentId ?? _RootMenuId;
         if (model.ID > 0)
         {
             dbContext.Update<Menu>(model);
         }
         else
         {
             model.Orderby = MaxOrderNumber(model.Parent ?? GetMenu(model.ParentId.Value));
             dbContext.Insert<Menu>(model);
         }
         Caching.Remove(cachingKey); //删除菜单缓存
     }
 }