Exemple #1
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));
        }
Exemple #2
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));
            }
        }
Exemple #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"));
        }
Exemple #4
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"));
        }