コード例 #1
0
        public VideoViewPlaylist GetVideosByPlaylist(GetPlatlistVideo getModel)
        {
            VideoViewPlaylist responseModel = new VideoViewPlaylist();
            var allplaylistByType           = _context.usp_GetPlaylistVideo
                                              .FromSql(SP_GetAllPlayListVideo,
                                                       new SqlParameter("playlistTypeId", getModel.playlistType))?
                                              .ToList();

            if (allplaylistByType != null)
            {
                var playlist = allplaylistByType.Where(x => x.id == getModel.playlistId)?.FirstOrDefault();
                if (playlist != null)
                {
                    responseModel.playlistDetail = _iMapper.Map <ViewPlaylist>(playlist);
                }

                var groupIdHierarchy = _context.uspGetGroupIdHierarchy
                                       .FromSql(SP_GetGroupIdHierarchy,
                                                new SqlParameter("groupId", getModel.playlistId))?
                                       .ToList();
                if (groupIdHierarchy != null)
                {
                    var lstGroupId = groupIdHierarchy.First().groupId.Split(',')
                                     .Where(x => !(string.IsNullOrEmpty(x) || string.IsNullOrWhiteSpace(x)))?
                                     .Select(x => new Guid(x)).ToList();
                    if (lstGroupId != null)
                    {
                        var similarPlaylist = allplaylistByType.Where(x => lstGroupId.Contains(x.id))?
                                              .OrderBy(x => x.createdDate)?
                                              .ToList();
                        if (similarPlaylist != null)
                        {
                            responseModel.lstSimilarPlaylist = _iMapper.Map <List <ViewPlaylist> >(similarPlaylist);
                        }

                        var playlist50 = allplaylistByType
                                         .Where(x => x.id != getModel.playlistId && lstGroupId.Contains(x.id))
                                         .OrderByDescending(x => x.createdDate).Take(50)?.ToList();
                        if (playlist50 != null)
                        {
                            responseModel.lstTop50Playlist = _iMapper.Map <List <ViewPlaylist> >(playlist50);
                        }
                    }
                }
            }

            var allplaylistVideos = _context.usp_GetVideosByPlaylistId
                                    .FromSql(SP_GetAllVideosByPlaylistId,
                                             new SqlParameter("groupId", getModel.playlistId))?
                                    .ToList();

            if (allplaylistVideos != null)
            {
                responseModel.playlistVideos = _iMapper.Map <List <ViewVideo> >(allplaylistVideos);
            }
            return(responseModel);
        }
コード例 #2
0
        public ActionResult GetVideosByPlaylist()
        {
            try
            {
                var getPlatlistVideo      = Request.Form["GetPlatlistVideo"];
                GetPlatlistVideo getModel = JsonConvert.DeserializeObject <GetPlatlistVideo>(getPlatlistVideo);

                if (getModel.playlistId == null || getModel.playlistType == 0)
                {
                    ModelState.AddModelError("error", "Playlist id and playlist type is required.");
                    return(BadRequest(ModelState));
                }
                return(Ok(_iPlaylistVideoService.GetVideosByPlaylist(getModel)));
            }
            catch (Exception ex)
            {
                _iLogger.LogCritical($"Exception while deleting a user", ex);
                return(StatusCode(500, "A problem happened while handling your request"));
            }
        }
コード例 #3
0
 public VideoViewPlaylist GetVideosByPlaylist(GetPlatlistVideo getModel)
 {
     return(this._playlistVideoRepository.GetVideosByPlaylist(getModel));
 }