|
|
|
@ -168,6 +168,35 @@ namespace Ombi.Core.Engine
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<RequestsViewModel<TvRequests>> GetRequestsLite(int count, int position, OrderFilterModel type)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
List<TvRequests> allRequests;
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite(shouldHide.UserId)
|
|
|
|
|
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
|
|
|
|
|
.Skip(position).Take(count).ToListAsync();
|
|
|
|
|
|
|
|
|
|
// Filter out children
|
|
|
|
|
|
|
|
|
|
FilterChildren(allRequests, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite()
|
|
|
|
|
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
|
|
|
|
|
.Skip(position).Take(count).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
|
|
|
|
|
return new RequestsViewModel<TvRequests>
|
|
|
|
|
{
|
|
|
|
|
Collection = allRequests
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
@ -218,6 +247,45 @@ namespace Ombi.Core.Engine
|
|
|
|
|
return allRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TvRequests>> GetRequestsLite()
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
List<TvRequests> allRequests;
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite(shouldHide.UserId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
FilterChildren(allRequests, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite().ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
return allRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<TvRequests> GetTvRequest(int requestId)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
TvRequests request;
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
{
|
|
|
|
|
request = await TvRepository.Get(shouldHide.UserId).Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
FilterChildren(request, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await CheckForSubscription(shouldHide, request);
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
|
|
|
|
{
|
|
|
|
|
// Filter out children
|
|
|
|
@ -225,16 +293,27 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
for (var j = 0; j < t.ChildRequests.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
var child = t.ChildRequests[j];
|
|
|
|
|
if (child.RequestedUserId != shouldHide.UserId)
|
|
|
|
|
{
|
|
|
|
|
t.ChildRequests.RemoveAt(j);
|
|
|
|
|
j--;
|
|
|
|
|
}
|
|
|
|
|
FilterChildren(t, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FilterChildren(TvRequests t, HideResult shouldHide)
|
|
|
|
|
{
|
|
|
|
|
// Filter out children
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < t.ChildRequests.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
var child = t.ChildRequests[j];
|
|
|
|
|
if (child.RequestedUserId != shouldHide.UserId)
|
|
|
|
|
{
|
|
|
|
|
t.ChildRequests.RemoveAt(j);
|
|
|
|
|
j--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
@ -470,7 +549,7 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
foreach (var tv in x.ChildRequests)
|
|
|
|
|
{
|
|
|
|
|
await CheckForSubscription(shouldHide, tv);
|
|
|
|
|
await CheckForSubscription(shouldHide, tv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|