public ProjectVM GetProjectById(int?id) { var project = id.HasValue ? _projects.FindById(id.Value) : _projects.FirstOrDefault(); var projectVM = Map <Project, ProjectVM>(project); projectVM.ProjectSections = _projectSections.GetSectionsByProjectId(project.Id).Select(x => new ProjectSectionVM { Id = x.Id, ProjectName = project.ProjectName, SectionName = x.SectionName, Description = x.Description, Images = _projectSectionImages.GetSectionImagesBySectionId(x.Id).Select(i => new ProjectSectionImageVM { Id = i.Id, Image = i.Image }) }).ToList(); return(projectVM); }