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)); }
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)); } }
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")); }