Ejemplo n.º 1
0
 //creates a new nodefieldmap and saves data
 public bool CreateAndSaveNodeData(Node node, Field field, dynamic data)
 {
     using (var dbt = _context.Database.BeginTransaction())
     {
         var nodedata = new NodeFieldMap()
         {
             Id = Guid.NewGuid(), NodeId = node.Id, FieldId = field.Id, NodeData = data.ToString()
         };
         nodedata = _context.NodeFieldMaps.Add(nodedata);
         _context.SaveChanges();
         dbt.Commit();
     }
     return(true);
 }
Ejemplo n.º 2
0
 public bool SaveNodeData(NodeFieldMap nodefieldmap)
 {
     using (var dbt = _context.Database.BeginTransaction())
     {
         var oldnodefieldmap = _context.NodeFieldMaps.Find(nodefieldmap.Id);
         if (oldnodefieldmap != null)
         {
             oldnodefieldmap.NodeData = nodefieldmap.NodeData;
             _context.SaveChanges();
             dbt.Commit();
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
 public bool RegisterFieldsForNode(IEntity node, List <Field> fields)
 {
     using (var dbt = _context.Database.BeginTransaction())
     {
         foreach (var field in fields)
         {
             var nodefieldmap = new NodeFieldMap()
             {
                 Id = Guid.NewGuid(), FieldId = field.Id, NodeId = node.Id, NodeData = string.Empty
             };
             nodefieldmap = _context.NodeFieldMaps.Add(nodefieldmap);
         }
         _context.SaveChanges();
         dbt.Commit();
     }
     return(true);
 }
Ejemplo n.º 4
0
        // Method to identify required FieldType and loads the corresponding HTML.
        public string GetRenderedField(string nodeid, string fieldid, string fieldrenderid = null)
        {
            var type  = GetFieldType(fieldid);
            var field = GetField(fieldid);
            var node  = _noderepo.GetNode(new Node()
            {
                Id = Guid.Parse(nodeid)
            });
            NodeFieldMap nodefieldmap = _noderepo.GetNodeFieldMap(new NodeFieldMap()
            {
                Id = Guid.Parse(fieldrenderid)
            });

            if (type != null)
            {
                var          fieldtype = System.Type.GetType(type.ClassPath);
                FieldContext _context  = new FieldContext(Guid.Parse(fieldrenderid ?? fieldid), field.FieldType.Id, field.FieldName);
                _context.Value = nodefieldmap == null ? string.Empty : nodefieldmap.NodeData;
                var fieldobj = Activator.CreateInstance(fieldtype, _context);
                var mi       = fieldtype.GetMethod("DoRender");
                return(mi.Invoke(fieldobj, null).ToString());
            }
            return(string.Empty);
        }