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();
     }
 }
 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();
     }
 }
 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();
     }
 }
Example #8
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();
     }
 }
 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();
     }
 }