// GET: /Story/Create public ActionResult Create() { var story = new Story(); story.Resources = new List<Resource>(); PopulateAssignedResources(story); return View(); }
private void PopulateAssignedResources(Story story) { var allStories = db.Stories; var linkedResources = story.Resources == null ? null : new HashSet<Resource>(story.Resources.Select(r => r)); var viewModel = new List<StoryViewModel>(); foreach (var r in allStories) { viewModel.Add(new StoryViewModel { Story = r, Resources = linkedResources, }); } ViewBag.Stories = viewModel; }