Esempio n. 1
0
 public static MenuItem GetDbRecord(int id)
 {
     using (var context = new BasicWebContext())
     {
         return(context.MenuItems.Find(id));
     }
 }
Esempio n. 2
0
 public static List <MenuItem> GetSubMenuItems(int id)
 {
     using (var context = new BasicWebContext())
     {
         return(context.MenuItems.Where(x => x.ParentID == id).ToList());
     }
 }
 public static List <T> Query <T>(System.Linq.Expressions.Expression <Func <T, bool> > condition) where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().Where(condition).ToList());
     }
 }
 public static List <T> GetAll <T>() where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().AsNoTracking().ToList());
     }
 }
 public static T Get <T>(object id) where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().Find(id));
     }
 }
Esempio n. 6
0
 public static void DeleteMenuItem(int id)
 {
     using (var context = new BasicWebContext())
     {
         context.MenuItems.Remove(context.MenuItems.Find(id));
         context.SaveChanges();
     }
 }
 public static void New <T>(T record) where T : class
 {
     using (var context = new BasicWebContext())
     {
         context.Set <T>().Add(record);
         context.SaveChanges();
     }
 }
 public static void Update <T>(object id, Action <T> action) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var record = context.Set <T>().Find(id);
         action(record);
         context.SaveChanges();
     }
 }
 public static void Delete <T>(object id) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var record = context.Set <T>().Find(id);
         context.Set <T>().Remove(record);
         context.SaveChanges();
     }
 }
Esempio n. 10
0
 public static Dictionary <int, string> GetAllOtherMenuItemNames(int currentID)
 {
     using (var context = new BasicWebContext())
     {
         var dict = context.MenuItems.ToDictionary(x => x.ID, x => x.Name);
         dict[0] = "<root>";
         dict.Remove(currentID);
         return(dict);
     }
 }
 public static void NewAll <T>(IEnumerable <T> records) where T : class
 {
     using (var context = new BasicWebContext())
     {
         foreach (var record in records)
         {
             context.Set <T>().Add(record);
         }
         context.SaveChanges();
     }
 }
 public static void UpdateAll <T>(System.Linq.Expressions.Expression <Func <T, bool> > selector, Action <T> action) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var records = context.Set <T>().Where(selector);
         foreach (var record in records)
         {
             action(record);
         }
         context.SaveChanges();
     }
 }
Esempio n. 13
0
 public static void EditMenuItem(int id, string name, string description, string type, string action, string icon, int parentID, int order, string allowedRoles)
 {
     using (var context = new BasicWebContext())
     {
         var record = context.MenuItems.Find(id);
         record.Name         = name;
         record.Description  = description;
         record.Type         = type;
         record.Action       = action;
         record.Icon         = icon;
         record.ParentID     = parentID;
         record.Order        = order;
         record.AllowedRoles = allowedRoles;
         context.SaveChanges();
     }
 }
Esempio n. 14
0
 public static void UpdateFromJson(WorkflowJsonObject flow)
 {
     using (var context = new TongJi.Web.Models.BasicWebContext())
     {
         foreach (var node in flow.nodes)
         {
             var flowNode = context.FlowNodes.Find(node.id);
             flowNode.Name = node.name;
             flowNode.FlowChartPositionX = node.xpos;
             flowNode.FlowChartPositionY = node.ypos;
             flowNode.AllowedUsers       = node.user;
             flowNode.AllowedRoles       = node.role;
         }
         context.SaveChanges();
     }
 }
Esempio n. 15
0
 public static void NewMenuItem(string name, string description, string type, string action, string icon, int parentID, int order, string allowedRoles)
 {
     using (var context = new BasicWebContext())
     {
         MenuItem item = new MenuItem
         {
             Name         = name,
             Description  = description,
             Type         = type,
             Action       = action,
             Icon         = icon,
             ParentID     = parentID,
             Order        = order,
             CreateTime   = DateTime.Now,
             AllowedRoles = allowedRoles
         };
         context.MenuItems.Add(item);
         context.SaveChanges();
     }
 }