|
|
|
@ -218,11 +218,61 @@ 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
|
|
|
|
|
foreach (var t in allRequests)
|
|
|
|
|
{
|
|
|
|
|
for (var j = 0; j < t.ChildRequests.Count; 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];
|
|
|
|
@ -232,7 +282,7 @@ namespace Ombi.Core.Engine
|
|
|
|
|
j--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId)
|
|
|
|
|