public async Task SwitchCollectionType()
        {
            await Task.Run(() => { SetActivityResource(false, true); });

            await Task.Run(() =>
            {
                CurrentCollectionType = CurrentCollectionType == YoutubeVideoCollectionType.Playlist
                    ? YoutubeVideoCollectionType.Channel
                    : YoutubeVideoCollectionType.Playlist;

                if (CurrentCollectionType == YoutubeVideoCollectionType.Playlist)
                {
                    PlaylistStyle = SelectedStyle;
                    ChannelStyle  = DefaultStyle;
                }
                else
                {
                    PlaylistStyle = DefaultStyle;
                    ChannelStyle  = SelectedStyle;
                }

                YoutubeItems = YoutubeVideos?.Where(v => v.VideoCollectionType == CurrentCollectionType)
                               .FirstOrDefault()?.YoutubeItems;
            });

            SetActivityResource();
        }
Exemple #2
0
        public static YoutubeVideos MostPopular(this YoutubeVideos videos)
        {
            var settings = videos.Settings.Clone();

            settings.Chart = Chart.MostPopular;
            return(Videos(settings, videos.PartTypes.ToArray()));
        }
Exemple #3
0
        public HttpResponseMessage GetYouTubeVideos(bool?IsPaid, bool?Approved, int CustomerId, int PageIndex, int MaxCount)
        {
            var response = this.Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                List <YoutubeVideos> list = new List <YoutubeVideos>();
                var facebookPosts         = _adCampaignService.GetYoutubeVideos(IsPaid, Approved, CustomerId, 0, int.MaxValue).ToList();
                foreach (var fblink in facebookPosts)
                {
                    YoutubeVideos fp = new YoutubeVideos();
                    fp.VideoLink   = fblink.VideoLink;
                    fp.CustomerId  = fblink.CustomerId;
                    fp.NoOfViews   = fblink.NoOfViews;
                    fp.IsPaid      = fblink.IsPaid;
                    fp.Approved    = fblink.Approved;
                    fp.Price       = fblink.Price;
                    fp.CreatedDate = fblink.CreatedDate;
                    list.Add(fp);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", data = list }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Some thing went wrong" }));
            }
        }
Exemple #4
0
        public static YoutubeVideos RequestId(this YoutubeVideos videos, params string[] ids)
        {
            var settings = videos.Settings.Clone();

            settings.Id = settings.Id.AddItems(ids);
            return(Videos(settings, videos.PartTypes.ToArray()));
        }
Exemple #5
0
 public static YoutubeVideos RequestAllParts(this YoutubeVideos videos)
 {
     return(videos.RequestContentDetails()
            .RequestStatistics()
            .RequestStatus()
            .RequestLocalizations()
            .RequestPlayer()
            .RequestTopicDetails()
            .RequestRecordingDetails()
            .RequestLiveStreamingDetails()
            .RequestSnippet());
 }
 public YoutubeVideos AddUpdateYoutubeVideo(YoutubeVideos youtubeVideos)
 {
     if (youtubeVideos.Id > 0)
     {
         _youtubeRepository.Update(youtubeVideos);
         return(youtubeVideos);
     }
     else
     {
         youtubeVideos.CreatedDate = DateTime.Now;
         _youtubeRepository.Insert(youtubeVideos);
         return(youtubeVideos);
     }
 }
        private async void PageLoad()
        {
            await Task.Run(() => { SetActivityResource(false, true); });

            YoutubeConfiguration = new YoutubeConfiguration();
            YoutubeConfiguration = await _youtubeDataServices.GetAsync();

            if (YoutubeConfiguration == null)
            {
                SetActivityResource();
                return;
            }

            CurrentCollectionType  = YoutubeVideoCollectionType.Channel;
            PlaylistCollectionType = YoutubeVideoCollectionType.Playlist.ToCapital();
            ChannelCollectionType  = YoutubeVideoCollectionType.Channel.ToCapital();

            foreach (var videoCollection in YoutubeConfiguration.YoutubeVideoCollection)
            {
                var videoCollectionIdApiUrl = "";
                if (YoutubeVideoCollectionType.Channel == videoCollection.VideoCollectionType)
                {
                    ChannelExists           = !string.IsNullOrEmpty(videoCollection.VideoCollectionApiKey);
                    videoCollectionIdApiUrl = string.Format(YoutubeConfiguration.VideoChannelApiUrl,
                                                            videoCollection.VideoCollectionApiKey, YoutubeConfiguration.UserApiKey);
                }
                else if (YoutubeVideoCollectionType.Playlist == videoCollection.VideoCollectionType)
                {
                    PlaylistExists          = !string.IsNullOrEmpty(videoCollection.VideoCollectionApiKey);
                    videoCollectionIdApiUrl = string.Format(YoutubeConfiguration.VideoPlaylistApiUrl,
                                                            videoCollection.VideoCollectionApiKey, YoutubeConfiguration.UserApiKey);
                }

                var stringList =
                    await GetVideoIdStringAsync(videoCollectionIdApiUrl, videoCollection.VideoCollectionType);

                var result = await GetVideosDetailsAsync(stringList, YoutubeConfiguration.VideoDetailApiUrl, YoutubeConfiguration.UserApiKey);

                YoutubeVideos.Add(new YoutubeVideo()
                {
                    VideoCollectionType = videoCollection.VideoCollectionType,
                    YoutubeItems        = result
                });
            }

            await SwitchCollectionType();
        }
Exemple #8
0
        public HttpResponseMessage AddYoutTubeVideo(YoutubeVideos youtubeVideos)
        {
            var response = this.Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var customerguid = Request.Headers.GetValues("CustomerGUID").FirstOrDefault();
                if (customerguid != null)
                {
                    var cust = _customerService.GetCustomerByGuid(Guid.Parse(customerguid));
                    if (youtubeVideos.CustomerId != cust.Id)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { code = 0, Message = "something went wrong" }));
                    }
                }
                if (youtubeVideos.VideoLink == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Invalid Url", data = "" }));
                }
                youtubeVideos.CustomerId  = youtubeVideos.CustomerId;
                youtubeVideos.NoOfViews   = 0;
                youtubeVideos.Price       = 0;
                youtubeVideos.IsPaid      = false;
                youtubeVideos.Deleted     = false;
                youtubeVideos.CreatedDate = DateTime.Now;
                youtubeVideos.Approved    = false;
                var youtubevideo = _adCampaignService.AddUpdateYoutubeVideo(youtubeVideos);
                var c            = JsonConvert.SerializeObject(youtubevideo, new JsonSerializerSettings
                {
                    Formatting            = Newtonsoft.Json.Formatting.Indented,
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                });
                return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", data = c }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Some thing went wrong" }));
            }
        }
Exemple #9
0
 public static YoutubeVideos RequestRecordingDetails(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.RecordingDetails));
 }
Exemple #10
0
 public static YoutubeVideos RequestTopicDetails(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.TopicDetails));
 }
Exemple #11
0
 public static IEnumerable <YoutubeVideo> TakePages(this YoutubeVideos videos, int pageCount)
 {
     return(videos.Take(videos.ResultsPerPage.GetValueOrDefault(ResultsPerPage) * pageCount));
 }
Exemple #12
0
 public static YoutubeVideos RequestPlayer(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.Player));
 }
Exemple #13
0
 public static YoutubeVideos RequestLocalizations(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.Localizations));
 }
Exemple #14
0
 public static YoutubeVideos RequestStatus(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.Status));
 }
Exemple #15
0
 public static YoutubeVideos RequestContentDetails(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.ContentDetails));
 }
Exemple #16
0
 public static YoutubeVideos RequestPart(this YoutubeVideos videos, PartType partType)
 {
     return(Videos(videos.Settings.Clone(), videos.PartTypes.Append(partType).ToArray()));
 }
Exemple #17
0
 public static IEnumerable <YoutubeVideo> TakePage(this YoutubeVideos videos)
 {
     return(videos.TakePages(1));
 }
Exemple #18
0
 public static YoutubeVideos RequestSnippet(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.Snippet));
 }
Exemple #19
0
 public static YoutubeVideos RequestLiveStreamingDetails(this YoutubeVideos videos)
 {
     return(videos.RequestPart(PartType.LiveStreamingDetails));
 }