|
|
@ -157,6 +157,8 @@ namespace Ombi.Core.Engine
|
|
|
|
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
|
|
|
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
|
|
|
|
|
|
|
return allRequests;
|
|
|
|
return allRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -182,25 +184,28 @@ namespace Ombi.Core.Engine
|
|
|
|
.ThenInclude(x => x.Episodes)
|
|
|
|
.ThenInclude(x => x.Episodes)
|
|
|
|
.Skip(position).Take(count).ToListAsync();
|
|
|
|
.Skip(position).Take(count).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
return ParseIntoTreeNode(allRequests);
|
|
|
|
return ParseIntoTreeNode(allRequests);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TvRequests>> GetRequests()
|
|
|
|
public async Task<IEnumerable<TvRequests>> GetRequests()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
IQueryable<TvRequests> allRequests;
|
|
|
|
List<TvRequests> allRequests;
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allRequests = TvRepository.Get(shouldHide.UserId);
|
|
|
|
allRequests = await TvRepository.Get(shouldHide.UserId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
FilterChildren(allRequests, shouldHide);
|
|
|
|
FilterChildren(allRequests, shouldHide);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allRequests = TvRepository.Get();
|
|
|
|
allRequests = await TvRepository.Get().ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return await allRequests.ToListAsync();
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
|
|
|
return allRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
|
|
|
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
|
|
@ -233,6 +238,8 @@ namespace Ombi.Core.Engine
|
|
|
|
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
|
|
|
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
|
|
|
|
|
|
|
return allRequests;
|
|
|
|
return allRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -249,6 +256,8 @@ namespace Ombi.Core.Engine
|
|
|
|
allRequests = TvRepository.Get();
|
|
|
|
allRequests = TvRepository.Get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
|
|
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
return results;
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -265,6 +274,7 @@ namespace Ombi.Core.Engine
|
|
|
|
allRequests = TvRepository.Get();
|
|
|
|
allRequests = TvRepository.Get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
|
|
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
|
|
|
|
|
|
|
results.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
return ParseIntoTreeNode(results);
|
|
|
|
return ParseIntoTreeNode(results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -446,6 +456,29 @@ namespace Ombi.Core.Engine
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task CheckForSubscription(HideResult shouldHide, TvRequests x)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var tv in x.ChildRequests)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await CheckForSubscription(shouldHide, tv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task CheckForSubscription(HideResult shouldHide, ChildRequests x)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (shouldHide.UserId == x.RequestedUserId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.ShowSubscribe = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.ShowSubscribe = true;
|
|
|
|
|
|
|
|
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s =>
|
|
|
|
|
|
|
|
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.TvShow);
|
|
|
|
|
|
|
|
x.Subscribed = sub != null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
|
|
|
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Add the child
|
|
|
|
// Add the child
|
|
|
|