|
|
@ -209,13 +209,13 @@ namespace Ombi.Core.Engine
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allRequests =
|
|
|
|
allRequests =
|
|
|
|
MovieRepository.GetWithUser(shouldHide
|
|
|
|
MovieRepository.GetWithUser(shouldHide
|
|
|
|
.UserId);
|
|
|
|
.UserId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allRequests =
|
|
|
|
allRequests =
|
|
|
|
MovieRepository
|
|
|
|
MovieRepository
|
|
|
|
.GetWithUser();
|
|
|
|
.GetWithUser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
|
|
|
|
var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
|
|
|
@ -230,8 +230,8 @@ namespace Ombi.Core.Engine
|
|
|
|
//var secondProp = TypeDescriptor.GetProperties(propType).Find(properties[1], true);
|
|
|
|
//var secondProp = TypeDescriptor.GetProperties(propType).Find(properties[1], true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
|
|
|
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
|
|
|
? allRequests.OrderBy(x => prop.GetValue(x))
|
|
|
|
? allRequests.OrderBy(x => prop.GetValue(x))
|
|
|
|
: allRequests.OrderByDescending(x => prop.GetValue(x));
|
|
|
|
: allRequests.OrderByDescending(x => prop.GetValue(x));
|
|
|
|
var total = await allRequests.CountAsync();
|
|
|
|
var total = await allRequests.CountAsync();
|
|
|
|
var requests = await allRequests.Skip(position).Take(count)
|
|
|
|
var requests = await allRequests.Skip(position).Take(count)
|
|
|
@ -246,9 +246,55 @@ namespace Ombi.Core.Engine
|
|
|
|
Collection = requests,
|
|
|
|
Collection = requests,
|
|
|
|
Total = total
|
|
|
|
Total = total
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<RequestsViewModel<MovieRequests>> GetUnavailableRequests(int count, int position, string sortProperty, string sortOrder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
|
|
|
IQueryable<MovieRequests> allRequests;
|
|
|
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
allRequests =
|
|
|
|
|
|
|
|
MovieRepository.GetWithUser(shouldHide
|
|
|
|
|
|
|
|
.UserId).Where(x => !x.Available);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
allRequests =
|
|
|
|
|
|
|
|
MovieRepository
|
|
|
|
|
|
|
|
.GetWithUser().Where(x => !x.Available);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sortProperty.Contains('.'))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// This is a navigation property currently not supported
|
|
|
|
|
|
|
|
prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find("RequestedDate", true);
|
|
|
|
|
|
|
|
//var properties = sortProperty.Split(new []{'.'}, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
//var firstProp = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(properties[0], true);
|
|
|
|
|
|
|
|
//var propType = firstProp.PropertyType;
|
|
|
|
|
|
|
|
//var secondProp = TypeDescriptor.GetProperties(propType).Find(properties[1], true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allRequests = sortOrder.Equals("asc", StringComparison.InvariantCultureIgnoreCase)
|
|
|
|
|
|
|
|
? allRequests.OrderBy(x => prop.GetValue(x))
|
|
|
|
|
|
|
|
: allRequests.OrderByDescending(x => prop.GetValue(x));
|
|
|
|
|
|
|
|
var total = await allRequests.CountAsync();
|
|
|
|
|
|
|
|
var requests = await allRequests.Skip(position).Take(count)
|
|
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
requests.ForEach(async x =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
|
|
|
|
|
|
|
await CheckForSubscription(shouldHide, x);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return new RequestsViewModel<MovieRequests>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Collection = requests,
|
|
|
|
|
|
|
|
Total = total
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<RequestEngineResult> UpdateAdvancedOptions(MovieAdvancedOptions options)
|
|
|
|
public async Task<RequestEngineResult> UpdateAdvancedOptions(MovieAdvancedOptions options)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var request = await MovieRepository.Find(options.RequestId);
|
|
|
|
var request = await MovieRepository.Find(options.RequestId);
|
|
|
|