private TitleDetailViewModel FillInViewModel(Title title) { var titleVM = new TitleDetailViewModel(title); foreach (var award in title.Awards) { titleVM.Awards.Add(new AwardViewModel(award)); } foreach (var participant in title.TitleParticipants) { titleVM.Participants.Add(new ParticipantViewModel(participant.Participant)); } foreach (var otherName in title.OtherNames) { titleVM.OtherNames.Add(new OtherNameViewModel(otherName)); } foreach (var storyLine in title.StoryLines) { titleVM.StoryLines.Add(new StoryLineViewModel(storyLine)); } foreach (var genre in title.TitleGenres) { titleVM.Genres.Add(new GenreViewModel(genre.Genre)); } return(titleVM); }
// // GET: /Home/Details public ActionResult Details(int id) { Title thisTitle = _db.Titles.Where(title => title.TitleId == id).SingleOrDefault(); var participants = from c in _db.Participants join cm in _db.TitleParticipants on c.Id equals cm.ParticipantId where (cm.TitleId == id && cm.RoleType == "Actor") select c; TitleDetailViewModel tdvm = new TitleDetailViewModel(); tdvm.thisTitle = thisTitle; tdvm.storylines = thisTitle.StoryLines.ToList(); tdvm.participants = participants.ToList(); return(View(tdvm)); }