public Application AddFieldsFromTemplate(ApplicationTemplate template) { if (Degrees?.Any() != true) { Degrees = template.Degrees.Select(d => new ApplicationDegree { Application = this, Index = d.Index, Degree = d.Name }).ToList(); } if (Documents?.Any() != true) { Documents = template.Documents.Select(d => new ApplicationDocument { Application = this, Index = d.Index, Name = d.Name, Description = d.Description }).ToList(); } if (References?.Any() != true) { References = new List <ApplicationReference>(); for (int i = 0; i < template.NumberOfReferences; ++i) { References.Add(new ApplicationReference { Application = this, Index = i }); } } return(this); }