/// <summary> /// /// </summary> /// <returns></returns> public Page <Clip> Get(int pindex, int psize, ClipFilter filter) { Page <Clip> result = new Page <Clip>(); result.PageIndex = pindex; result.PageSize = psize; string query = @" SELECT DISTINCT [Clip].* FROM [clip] LEFT JOIN [Cut] ON [Cut].[IdClip] = [Clip].[Id] LEFT JOIN [Video] AS [V] ON [V].[Id] = [Cut].[IdVideo] WHERE ([V].[IdChannel] = @IdChannel OR @IdChannel IS NULL) AND ([Clip].[Status] = @Status OR @Status IS NULL) AND ([Clip].[CreatedAt] >= @CreateAt OR @CreateAt IS NULL) ORDER BY [Clip].[Id] DESC OFFSET @Psize * @Pindex ROWS FETCH NEXT @Psize ROWS ONLY;"; string qcount = @" SELECT COUNT(DISTINCT [Clip].[Id]) FROM [clip] LEFT JOIN [Cut] ON [Cut].[IdClip] = [Clip].[Id] LEFT JOIN [Video] AS [V] ON [V].[Id] = [Cut].[IdVideo] WHERE ([V].[IdChannel] = @IdChannel OR @IdChannel IS NULL) AND ([Clip].[Status] = @Status OR @Status IS NULL) AND ([Clip].[CreatedAt] >= @CreateAt OR @CreateAt IS NULL)" ; var count = this.Context.ExecuteScalar(qcount, filter); result.Total = Convert.ToInt32(count); result.Result = this.Context.Query <Clip>(query, filter); result.Result.ToList().ForEach(o => o.SocialMedias = GetSocialMedias(o.Id)); return(result); }
public Page <Clip> Get(int pindex, int psize, ClipFilter filter) { filter.Psize = psize; filter.Pindex = pindex - 1; int STATUS_PROCESSED = 2; var clips = this._clipRepository.Get(pindex, psize, filter); foreach (var item in clips.Result) { if (item.Status == STATUS_PROCESSED) { if (item.SocialMedias.Any(sm => sm.Status != STATUS_PROCESSED)) { item.Status = 3; } } } return(clips); }
public Page <Clip> Get(int psize, int pindex, [FromQuery] ClipFilter filter) { return(this.svc.Get(pindex, psize, filter)); }