public void PublishList(SocialList list) { XmlDocument xml = new XmlDocument(); XmlElement xSocialList = xml.CreateElement("socialList"); xSocialList.SetAttribute("name", list.Name); xSocialList.SetAttribute("id", list.Id); foreach (var post in list.MediaPosts) { XmlElement xMediaPost = xml.CreateElement("mediaPost"); xMediaPost.SetAttribute("platform", post.MediaPlatform); xMediaPost.SetAttribute("postId", post.PostId); XmlElement xUser = xml.CreateElement("user"); xUser.SetAttribute("displayName", post.DisplayName); xUser.SetAttribute("mediaHandle", post.MediaHandle); xMediaPost.AppendChild(xUser); XmlElement xMain = xml.CreateElement("mainContent"); xMain.SetAttribute("value", post.MainContent); xMediaPost.AppendChild(xMain); XmlElement xSecondary = xml.CreateElement("secondaryContent"); xSecondary.SetAttribute("value", post.SecondaryContent); xMediaPost.AppendChild(xSecondary); XmlElement xAttachments = xml.CreateElement("attachments"); foreach (var attachment in post.Attachments) { XmlElement xAttachment = xml.CreateElement("attachment"); XmlElement xAttachmentUser = xml.CreateElement("user"); xAttachmentUser.SetAttribute("displayName", attachment.DisplayName); xAttachmentUser.SetAttribute("mediaHandle", attachment.MediaHandle); xAttachment.AppendChild(xAttachmentUser); XmlElement xAttachmentMain = xml.CreateElement("mainContent"); xAttachmentMain.SetAttribute("value", attachment.MainContent); xAttachment.AppendChild(xAttachmentMain); XmlElement xAttachmentSecondary = xml.CreateElement("secondaryContent"); xAttachmentSecondary.SetAttribute("value", attachment.SecondaryContent); xAttachment.AppendChild(xAttachmentSecondary); xAttachments.AppendChild(xAttachment); } xMediaPost.AppendChild(xAttachments); xSocialList.AppendChild(xMediaPost); } xml.AppendChild(xSocialList); Directory.CreateDirectory(_publishDirectory); var filename = list.Name.Replace(' ', '_') + ".xml"; xml.Save(Path.Combine(_publishDirectory, filename)); }
private static IEnumerable <SocialListPerson> GetSeedData() { var people1 = new List <Person> { new Person { Name = "John", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "johnlennon", Network = "twitter", PersonId = 1 } } }, new Person { Name = "Paul", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "paulmccartney", Network = "twitter", PersonId = 2 } } }, new Person { Name = "George", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "georgeharrison", Network = "twitter", PersonId = 3 } } }, new Person { Name = "Ringo", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "ringostar", Network = "twitter", PersonId = 4 } } } }; var list1 = new SocialList { Name = "The Beatles" }; var list2 = new SocialList { Name = "Paul McCartney and Wings" }; var data = people1 .Select(x => new SocialListPerson { Person = x, SocialList = list1 }) .Concat(new List <SocialListPerson> { new SocialListPerson { Person = people1[1], SocialList = list2 } }) .ToList(); return(data); }
public static IEnumerable <SocialList> GetSeedData() { var people1 = new List <Person> { new Person { PersonId = 1, Name = "John", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "johnlennon", Network = "twitter", PersonId = 1 } } }, new Person { PersonId = 2, Name = "Paul", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "paulmccartney", Network = "twitter", PersonId = 2 } } }, new Person { PersonId = 3, Name = "George", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "georgeharrison", Network = "twitter", PersonId = 3 } } }, new Person { PersonId = 4, Name = "Ringo", Accounts = new List <SocialAccount> { new SocialAccount { AccountName = "ringostar", Network = "twitter", PersonId = 4 } } } }; var list1 = new SocialList { SocialListId = 1, Name = "The Beatles", SocialListPerson = people1.Select(x => new SocialListPerson { Person = x, PersonId = x.PersonId }).ToList() }; var list2 = new SocialList { SocialListId = 2, Name = "Paul McCartney and Wings", SocialListPerson = new SocialListPerson[] { new SocialListPerson { Person = people1[1], PersonId = people1[1].PersonId } } }; return(new SocialList[] { list1, list2 }); }