// // GET: /Story/Create public ActionResult Create(int parentId) { var model = new Story(); var parent = _storyRepository.GetById(parentId); parent.AddChildStory(model); return View(model); }
public ActionResult Create(Story story) { try { _storyRepository.Add(story); return View("Details", _storyRepository.GetLeafNodes(story.Parent.Id)); } catch { return View(); } }
public ActionResult Delete(Story story) { try { story = _storyRepository.GetById(story.Id); _storyRepository.Delete(story); //do we have any leaves left? if (_storyRepository.GetLeafNodes(story.Parent.Id).Count <= 0) { var next = _storyRepository.GetAllAncestorsOfStory(story.Parent.Id).First(); return View("Details", _storyRepository.GetLeafNodes(next.Id)); } else { return View("Details", _storyRepository.GetLeafNodes(story.Parent.Id)); } } catch { return View(); } }
public virtual void AddChildStory(Story Story) { Children.Add(Story); Story.Parent = this; }