public void SeedDummyRecords()
        {
            var queryBuilder = new FluentQueryBuilder();
            AddMembership(queryBuilder);
            AddEntities(queryBuilder);
            queryBuilder.Execute(GraphClient.Cypher);

        }
        public IHttpActionResult SaveScreen([FromBody] List<KeyValuePair<SaveEntityVm, List<SavePropertyVm>>> saveData)
        {
            var queryBuilder = new FluentQueryBuilder();

            foreach (var saveGroup in saveData)
            {
                var entity = new Entity() { guid = saveGroup.Key.entityGuid };
                var entityInstance = new EntityInstance() { guid = saveGroup.Key.entityInstanceGuid };

                queryBuilder.Merge(entityInstance);
                queryBuilder.RelateTo(entityInstance, new InstanceOf(), entity);

                foreach (var propertyGroup in saveGroup.Value)
                {

                    var property = new Property() { guid = propertyGroup.propertyGuid };

                    if (propertyGroup.type == "dataProperty")
                    {
                        var propertyValue = new PropertyValue() {guid = Guid.NewGuid().ToString("N"), value = propertyGroup.value};
                        queryBuilder.Merge(propertyValue);
                        queryBuilder.Replace(entityInstance, new HasPropertyValue(), new PropertyValue(), entityInstance, new HasPropertyValue(), propertyValue, property);
                        queryBuilder.RelateTo(propertyValue, new IsValueForProperty(), property);
                    }
                    else if (propertyGroup.type == "entityProperty")
                    {
                        var propertyValueInstance = new EntityInstance() { guid = propertyGroup.value };
                        queryBuilder.Replace(entityInstance, new HasPropertyValue(), new EntityInstance(), entityInstance, new HasPropertyValue(), propertyValueInstance, property);
                        queryBuilder.RelateTo(propertyValueInstance, new IsValueForProperty(), property);
                    }

                    
                }

            }

            queryBuilder.Execute(StagedDbContext.Instance.GraphClient.Cypher);

            
            return Ok();
        }
        public IHttpActionResult Insert([FromBody] CreateScreenVm value)
        {
            var queryBuilder = new FluentQueryBuilder();
            var templates = Enum.GetValues(typeof(TemplateEnum)).Cast<TemplateEnum>().ToList().Select(t => t.ToTemplateVm());

            var matchingTemplate = templates.First(t => t.name == value.screen.template.name);

            var screen = new Screen() { guid = Guid.NewGuid().ToString("N"), name = "New Screen" };
            var template = new Template()
            {
                guid = Guid.NewGuid().ToString("N"),
                name = value.screen.template.name,
                location = matchingTemplate.location
            };

            queryBuilder
                .Create(screen)
                .Create(template)
                .RelateTo(screen, new HasTemplate(), template)
                .RelateTo(StagedDbContext._application, new HasScreen { screenType = value.screen.screenType }, screen)
                
                ;


            foreach (var widget in value.screen.template.widgets)
            {
                var widgetNode = new Widget { guid = Guid.NewGuid().ToString("N"), widgetSchema = widget.widget };

                var propertyNode = new Property() { guid = widget.data.guid };


                queryBuilder
                    .Create(widgetNode)
                    .RelateTo(template, new HasWidget(), widgetNode)
                    .RelateTo(widgetNode, new DisplaysValueFor(), propertyNode)
                    ;

                if (widget.data.next == null || widget.data.next.guid == null) continue;


                if (widget.data.next.next == null || widget.data.next.next.guid == null)
                {
                    var entityPropertyNode = new Property() { guid = widget.data.next.guid };
                    queryBuilder
                        .RelateTo(widgetNode, new ForThisHeaderProperty(), entityPropertyNode);
                }
                else
                {
                    var entityPropertyNode = new Property() { guid = widget.data.next.next.guid };
                    queryBuilder
                        .RelateTo(widgetNode, new ForThisHeaderProperty(), entityPropertyNode);
                }





            }
            

            queryBuilder.Execute(StagedDbContext.Instance.GraphClient.Cypher);

            
            return Ok();
        }