Created
July 11, 2014 11:52
-
-
Save Vannevelj/49561224980d0d52838d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static IEnumerable<string> InsertIntoChannelsTable(Channel channel) | |
{ | |
foreach (var profile in channel.Profiles) | |
{ | |
yield return new InsertQueryBuilder() | |
.WithTable("Channels") | |
.WithColumn("channel_id", profile.Id) | |
.WithColumn("channel_background", profile.Background) | |
.WithColumn("channel_background_position", profile.Position) | |
.WithColumn("channel_logo", profile.Logo) | |
.WithColumn("channel_logo_position", profile.LogoPosition) | |
.WithColumn("pdf_tpl_front", profile.PdfTplFront) | |
.WithColumn("pdf_tpl_blanc", profile.PdfTplBlanc) | |
.WithColumn("pdf_tpl_back", profile.PdfTplBack) | |
.WithColumn("pdf_header_offset", profile.PdfHeaderOffset) | |
.WithColumn("pdf_footer_offset", profile.PdfFooterOffset) | |
.GetResult(); | |
foreach (var structure in profile.Structures) | |
{ | |
foreach (var query in GetNestedStructures(structure)) | |
{ | |
yield return query; | |
} | |
} | |
} | |
} | |
private static IEnumerable<string> GetNestedStructures(Structure structure) | |
{ | |
yield return new InsertQueryBuilder() | |
.WithTable("Structures") | |
.WithColumn("structure_uri", new Guid()) //TODO: replace with actual URI | |
.WithColumn("structure_id", structure.Id) | |
.WithColumn("structure_type", structure.Type) | |
.WithColumn("structure_name", structure.Name) | |
.WithColumn("structure_sensitive", structure.Sensitive) | |
.WithColumn("structure_label_hidden", structure.LabelHidden) | |
.WithColumn("structure_asset_id", structure.FileId) | |
.WithColumn("structure_description", structure.Description) | |
.WithColumn("structure_slug", structure.Slug) | |
.GetResult(); | |
if (structure.Structures != null && structure.Structures.Any()) | |
{ | |
foreach (var subStructure in structure.Structures) | |
{ | |
foreach (var query in GetNestedStructures(subStructure)) | |
{ | |
yield return query; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment