Esempio n. 1
0
        public IActionResult GetUploaderVideos(int uploaderId)
        {
            var uploaderVideos = _vpRepository
                                 .FindBy(vp => vp.UploaderId == uploaderId, vp => vp.Uploader, vp => vp.Country, vp => vp.Uploader, vp => vp.Category);

            if (uploaderVideos == null)
            {
                return(NotFound());
            }

            var uploaderVideosVM = Mapper.Map <IEnumerable <VideoPost>, IEnumerable <VideoPostVM> >(uploaderVideos);

            return(new OkObjectResult(uploaderVideosVM));
        }
        public IActionResult GetAllSearchResult()
        {
            var allVideoPosts = _vpRepository
                                .FindBy(vp => !vp.IsDisabled, vp => vp.Country, vp => vp.Uploader).OrderByDescending(vp => vp.Likes);

            if (allVideoPosts == null)
            {
                return(NotFound());
            }

            var allVideoVM = Mapper.Map <IEnumerable <VideoPost>, IEnumerable <VideoPostVM> >(allVideoPosts);

            foreach (var av in allVideoVM)
            {
                if (av.Uploader.Trim().Length > 6)
                {
                    var substringed = av.Uploader.Substring(0, 6);
                    av.Uploader = string.Concat(substringed + "..");
                }
            }

            return(new OkObjectResult(allVideoVM));
        }
Esempio n. 3
0
        public async Task <IActionResult> GetMyVideos()
        {
            var user = await _userManager.FindByIdAsync(User.Identity.Name);

            if (user == null)
            {
                return(NotFound());
            }

            var myVideos  = _mvRepository.FindBy(mv => mv.ApplicationUserId == user.Id);
            var allVideos = _vpRepository.FindBy(vp => !vp.IsDisabled, vp => vp.Country, vp => vp.Uploader, vp => vp.Category);

            if (myVideos == null || allVideos == null)
            {
                return(NotFound());
            }

            var myVideoPosts = new List <VideoPost>();

            foreach (var av in allVideos)
            {
                if (myVideos.Any(mv => mv.VideoPostId == av.VideoPostId))
                {
                    myVideoPosts.Add(av);
                }
            }

            var allMyVideosVM = Mapper.Map <IEnumerable <VideoPost>, IEnumerable <VideoPostVM> >(myVideoPosts);

            foreach (var av in allMyVideosVM)
            {
                if (av.Uploader.Trim().Length > 6)
                {
                    var substringed = av.Uploader.Substring(0, 6);
                    av.Uploader = string.Concat(substringed + "..");
                }
            }

            return(new OkObjectResult(allMyVideosVM));
        }