Esempio n. 1
0
        public ActionResult Create(PredicateCreateModel model)
        {
            if (model == null)
            {
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                PredicateManager predicateManager = new PredicateManager();

                Predicate newPredicate = new Predicate();
                newPredicate.Name        = model.Name;
                newPredicate.Description = model.Name;

                //get parent
                var parent = predicateManager.Get(model.ParentId);

                newPredicate.Parent = parent;

                predicateManager.Create(newPredicate);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult Edit(PredicateCreateModel model)
        {
            if (model == null)
            {
                return(View(model));
            }

            PredicateManager predicateManager = new PredicateManager();
            var predicate = predicateManager.Get(model.Id);

            if (predicate != null)
            {
                try
                {
                    predicate.Name        = model.Name;
                    predicate.Description = model.Description;
                    //get parent
                    var parent = predicateManager.Get(model.ParentId);
                    predicate.Parent = parent;

                    predicateManager.Update(predicate);

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "Ein Fehler ist aufgetreten. " + ex.Message);
                }
            }

            LoadSelectionOfParentPredicates();

            ModelState.AddModelError("", "Das Prädikat konnte nicht aktualisiert werden.");
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Delete(long id)
        {
            if (id > 0)
            {
                InteractionManager interactionManager = new InteractionManager();
                SubjectManager     subjectManager     = new SubjectManager();
                PredicateManager   predicateManager   = new PredicateManager();

                //get all interaction with this predicate
                var interactions = interactionManager.GetAll().Where(i => i.Predicate.Id.Equals(id));

                // delete the interactions
                foreach (var interaction in interactions)
                {
                    interactionManager.Delete(interaction);
                }

                // delete the predictae

                var predicate = predicateManager.Get(id);
                if (predicate != null)
                {
                    predicateManager.Delete(predicate);
                }
            }

            return(RedirectToAction("Index"));
        }
        //Finds a collection of entities with the specified query.

        public virtual async Task <IEnumerable <TEntity> > Where(Expression <Func <TEntity, bool> > query)
        {
            string  name   = query.Parameters[0].Name;
            TEntity entity = (TEntity)Activator.CreateInstance(query.Parameters[0].Type);
            Expression <Func <TEntity, bool> > newQuery = PredicateManager.Rewrite(query, "e");

            return(await client.Cypher
                   .Match("(e:" + entity.Label + ")")
                   .Where(newQuery)
                   .Return(e => e.As <TEntity>())
                   .ResultsAsync);
        }
Esempio n. 5
0
        public ActionResult CheckPredicate(string name, string initName)
        {
            PredicateManager predicateManager = new PredicateManager();

            string defaultstring = "";

            if (!String.IsNullOrEmpty(initName))
            {
                defaultstring = initName;
            }

            if (predicateManager.GetAll().Any(n => n.Name != null && n.Name.Equals(name) && !n.Name.Equals(initName)))
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        public virtual async Task <IEnumerable <TEntity2> > GetRelated <TEntity2, TRelationship>(Expression <Func <TEntity, bool> > query1, Expression <Func <TEntity2, bool> > query2, TRelationship relationship)
            where TEntity2 : Neo4jEntity, new()
            where TRelationship : Neo4jRelationship, new()
        {
            string   name1   = query1.Parameters[0].Name;
            TEntity  entity1 = (TEntity)Activator.CreateInstance(query1.Parameters[0].Type);
            string   name2   = query2.Parameters[0].Name;
            TEntity2 entity2 = (TEntity2)Activator.CreateInstance(query2.Parameters[0].Type);

            Expression <Func <TEntity2, bool> > newQuery = PredicateManager.Rewrite(query2, "e");

            return(await client.Cypher
                   .Match("(" + name1 + ":" + entity1.Label + ")-[:" + relationship.Name + "]->(" + name2 + ":" + entity2.Label + ")")
                   .Where(query1)
                   .AndWhere(query2)
                   .Return(e => e.As <TEntity2>())
                   .ResultsAsync);
        }
Esempio n. 7
0
        public ActionResult Edit(long id)
        {
            LoadSelectionOfParentPredicates();

            PredicateManager predicateManager = new PredicateManager();
            var predicate = predicateManager.Get(id);

            if (predicate != null)
            {
                PredicateCreateModel model = new PredicateCreateModel();
                model.Id          = predicate.Id;
                model.Name        = predicate.Name;
                model.Description = predicate.Description;
                model.ParentId    = predicate.Parent != null ? predicate.Parent.Id : 0;

                return(View(model));
            }

            return(Redirect("Create"));
        }