Example #1
0
        public async Task <List <VideoChannel> > GetChannels(bool onlyEditable)
        {
            // https://mod421769.sharepoint.com/portals/hub/_api/videoservice/Channels?$top=2000&$skip=0&$select=id,title,tilehtmlcolor&$orderby=title
            // "https://mod421769.sharepoint.com/portals/hub"
            var url   = SpHelper.GetVideoPortalRootUrl();
            var query = onlyEditable
              ? await SpHelper.GetVideoPortalRootUrl() + "/_api/VideoService/CanEditChannels"
              : await SpHelper.GetVideoPortalRootUrl() + "/_api/VideoService/Channels?$top=2000&$skip=0&$select=id,title,tilehtmlcolor&$orderby=title";

            // create request for channels
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, query);

            // issue request & get response
            var response = await _client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            // convert response to object
            var jsonResponse = JsonConvert.DeserializeObject <JsonHelpers.VideoChannelCollection>(responseString);

            // convert to model object
            var channels = new List <VideoChannel>();

            foreach (var videoChannel in jsonResponse.Data.Results)
            {
                var channel = new VideoChannel
                {
                    Id                = videoChannel.Id,
                    HtmlColor         = videoChannel.TileHtmlColor,
                    Title             = videoChannel.Title,
                    Description       = videoChannel.Description,
                    ServerRelativeUrl = videoChannel.ServerRelativeUrl
                };
                channels.Add(channel);
            }

            return(channels.OrderBy(vc => vc.Title).ToList());
        }
Example #2
0
        public async Task <VideoChannel> GetChannel(string channelId)
        {
            var query = string.Format("{0}/_api/VideoService/Channels('{1}')", await SpHelper.GetVideoPortalRootUrl(), channelId);

            // issue request & get response
            var response = await _client.GetAsync(query);

            string responseString = await response.Content.ReadAsStringAsync();

            // convert response to object
            var jsonResponse = JsonConvert.DeserializeObject <JsonHelpers.VideoChannelSingle>(responseString);

            var channel = new VideoChannel
            {
                Id                = jsonResponse.Data.Id,
                HtmlColor         = jsonResponse.Data.TileHtmlColor,
                Title             = jsonResponse.Data.Title,
                Description       = jsonResponse.Data.Description,
                ServerRelativeUrl = jsonResponse.Data.ServerRelativeUrl
            };

            return(channel);
        }