public async Task AddSiteContentsAsync(VideoPortalHelper videoPortalHelper)
        {
            replaceTenantId(sampleData);

            //add items to Properties list
            CSOMUtil.AddListItems(clientContext, "Properties", sampleData);

            //add items to Rooms list
            CSOMUtil.AddListItems(clientContext, "Rooms", sampleData);

            //add items to Inspections list
            CSOMUtil.AddListItems(clientContext, "Inspections", sampleData);

            //add items to Inspection Comments list
            CSOMUtil.AddListItems(clientContext, "Inspection Comments", sampleData);

            //add items to Incidents list
            CSOMUtil.AddListItems(clientContext, "Incidents", sampleData);

            //add items to Room Inspection Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Room Inspection Photos", sampleData);

            //add items to Repair Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Repair Photos", sampleData);

            //add items to Property Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Property Photos", sampleData);

            //upload demo videos to Video Portal
            await ProvisionDemoVideosAsync(videoPortalHelper, "Videos", sampleData);
        }
        public async Task ProvisionDemoVideosAsync(VideoPortalHelper videoPortalHelper, string listTitle, XmlDocument sampleData)
        {
            var items = sampleData.SelectSingleNode("//List[@name='" + listTitle + "']");

            foreach (XmlNode item in items)
            {
                string videoTitle        = item.Attributes["Title"].Value;
                string videoDescription  = item.Attributes["Description"].Value;
                string ChannelName       = item.Attributes["ChannelName"].Value;
                string videoPhysicalPath = HttpContext.Current.Server.MapPath("../") + item.Attributes["path"].Value;

                var match = Regex.Match(videoTitle, @"(?is)(?<=\[)(.*)(?=\])");
                int index = match.Success ? int.Parse(match.Captures[0].Value) : 0;
                if (index > 0)
                {
                    string newId = sampleData.SelectNodes("//List[@name='Incidents']/item")[index - 1].ChildNodes[0].InnerText;
                    videoTitle = videoTitle.Replace("[" + index.ToString() + "]", "[" + newId + "]");
                    await videoPortalHelper.UploadVideoAsync(ChannelName, videoPhysicalPath, videoTitle, videoDescription);
                }
            }
        }
        public async Task ProvisionDemoVideosAsync(VideoPortalHelper videoPortalHelper, string listTitle, XmlDocument sampleData)
        {
            var items = sampleData.SelectSingleNode("//List[@name='" + listTitle + "']");

            foreach (XmlNode item in items)
            {
                string videoTitle = item.Attributes["Title"].Value;
                string videoDescription = item.Attributes["Description"].Value;
                string ChannelName = item.Attributes["ChannelName"].Value;
                string videoPhysicalPath = HttpContext.Current.Server.MapPath("../") + item.Attributes["path"].Value;

                var match = Regex.Match(videoTitle, @"(?is)(?<=\[)(.*)(?=\])");
                int index = match.Success ? int.Parse(match.Captures[0].Value) : 0;
                if (index > 0)
                {
                    string newId = sampleData.SelectNodes("//List[@name='Incidents']/item")[index - 1].ChildNodes[0].InnerText;
                    videoTitle = videoTitle.Replace("[" + index.ToString() + "]", "[" + newId + "]");
                    await videoPortalHelper.UploadVideoAsync(ChannelName, videoPhysicalPath, videoTitle, videoDescription);
                }
            }
        }
        public async Task AddSiteContentsAsync(VideoPortalHelper videoPortalHelper)
        {
            replaceTenantId(sampleData);

            //add items to Properties list
            CSOMUtil.AddListItems(clientContext, "Properties", sampleData);

            //add items to Rooms list
            CSOMUtil.AddListItems(clientContext, "Rooms", sampleData);

            //add items to Inspections list
            CSOMUtil.AddListItems(clientContext, "Inspections", sampleData);

            //add items to Inspection Comments list
            CSOMUtil.AddListItems(clientContext, "Inspection Comments", sampleData);

            //add items to Incidents list
            CSOMUtil.AddListItems(clientContext, "Incidents", sampleData);

            //add items to Room Inspection Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Room Inspection Photos", sampleData);

            //add items to Repair Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Repair Photos", sampleData);

            //add items to Property Photos list
            CSOMUtil.AddDocumentLibItems(clientContext, "Property Photos", sampleData);

            //upload demo videos to Video Portal
            await ProvisionDemoVideosAsync(videoPortalHelper, "Videos", sampleData);
        }
        private async Task<Video[]> GetVideosAsync(string ChannelName, int incidentId)
        {
            var helper = new VideoPortalHelper(_token);
            var videos = await helper.GetVideosAsync(ChannelName, incidentId.ToString());

            return videos.Select(v => new Video
            {
                Title = v["Title"],
                ThumbnailUrl = v["ThumbnailUrl"],
                YammerObjectUrl = v["YammerObjectUrl"]
            }).ToArray();
        }