More fixed for EF core

pull/3528/head
Jamie Rees 5 years ago
parent 4f9579e7bf
commit 6c3ae89ca0

@ -136,7 +136,7 @@ namespace Ombi.Core.Engine
{
var user = await GetUser();
var existingSub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(x =>
x.UserId.Equals(user.Id) && x.RequestId == requestId && x.RequestType == type);
x.UserId == user.Id && x.RequestId == requestId && x.RequestType == type);
if (existingSub != null)
{
return;
@ -155,7 +155,7 @@ namespace Ombi.Core.Engine
{
var user = await GetUser();
var existingSub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(x =>
x.UserId.Equals(user.Id) && x.RequestId == requestId && x.RequestType == type);
x.UserId == user.Id && x.RequestId == requestId && x.RequestType == type);
if (existingSub != null)
{
await _subscriptionRepository.Delete(existingSub);

@ -24,7 +24,8 @@ namespace Ombi.Core.Rule.Rules.Request
public async Task<RuleResult> Execute(BaseRequest obj)
{
var user = await _manager.Users.FirstOrDefaultAsync(x => x.UserName.Equals(User.Identity.Name, StringComparison.InvariantCultureIgnoreCase));
var username = User.Identity.Name.ToUpper();
var user = await _manager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username);
if (await _manager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser)
{
obj.Approved = true;

@ -25,7 +25,8 @@ namespace Ombi.Core.Rule.Rules.Request
public async Task<RuleResult> Execute(BaseRequest obj)
{
var user = await _manager.Users.FirstOrDefaultAsync(x => x.UserName.Equals(User.Identity.Name, StringComparison.InvariantCultureIgnoreCase));
var username = User.Identity.Name.ToUpper();
var user = await _manager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username);
if (await _manager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser)
return Success();

@ -41,7 +41,7 @@ namespace Ombi.Core.Rule.Rules.Request
{
// Let's check imdbid
existing = await movieRequests.FirstOrDefaultAsync(x =>
x.ImdbId.Equals(movie.ImdbId, StringComparison.CurrentCultureIgnoreCase));
x.ImdbId == movie.ImdbId);
if (existing != null)
{
found = true;

@ -32,13 +32,13 @@ namespace Ombi.Core.Rule.Rules.Request
var tvContent = _plexContent.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show);
// We need to do a check on the TVDBId
var anyTvDbMatches = await tvContent.Include(x => x.Episodes).FirstOrDefaultAsync(x => x.HasTvDb && x.TvDbId.Equals(tvRequest.Id.ToString(), StringComparison.InvariantCultureIgnoreCase)); // the Id on the child is the tvdbid at this point
var anyTvDbMatches = await tvContent.Include(x => x.Episodes).FirstOrDefaultAsync(x => x.HasTvDb && x.TvDbId == tvRequest.Id.ToString()); // the Id on the child is the tvdbid at this point
if (anyTvDbMatches == null)
{
// So we do not have a TVDB Id, that really sucks.
// Let's try and match on the title and year of the show
var titleAndYearMatch = await tvContent.Include(x=> x.Episodes).FirstOrDefaultAsync(x =>
x.Title.Equals(tvRequest.Title, StringComparison.InvariantCultureIgnoreCase)
x.Title == tvRequest.Title
&& x.ReleaseYear == tvRequest.ReleaseYear.Year.ToString());
if (titleAndYearMatch != null)
{

@ -24,7 +24,7 @@ namespace Ombi.Core.Rule.Rules.Search
{
// Check if it's in Lidarr
var result = _db.GetAll().FirstOrDefault(x =>
x.ForeignAlbumId.Equals(obj.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
x.ForeignAlbumId == obj.ForeignAlbumId);
if (result != null)
{
obj.PercentOfTracks = result.PercentOfTracks;
@ -36,7 +36,7 @@ namespace Ombi.Core.Rule.Rules.Search
{
// Check if it's in Lidarr
var result = _db.GetAll().FirstOrDefault(x =>
x.ForeignAlbumId.Equals(release.Id, StringComparison.InvariantCultureIgnoreCase));
x.ForeignAlbumId == release.Id);
if (result != null)
{
release.PercentOfTracks = result.PercentOfTracks;

@ -21,7 +21,7 @@ namespace Ombi.Core.Rule.Rules.Search
{
var obj = (SearchArtistViewModel) objec;
// Check if it's in Lidarr
var result = _db.GetAll().FirstOrDefault(x => x.ForeignArtistId.Equals(obj.ForignArtistId, StringComparison.InvariantCultureIgnoreCase));
var result = _db.GetAll().FirstOrDefault(x => x.ForeignArtistId == obj.ForignArtistId);
if (result != null)
{
obj.Monitored = true; // It's in Lidarr so it's monitored

@ -126,7 +126,7 @@ namespace Ombi.Core.Senders
var album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
var albumToSearch = album.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
x.foreignAlbumId == model.ForeignAlbumId);
var maxRetryCount = 10; // 5 seconds
var currentRetry = 0;
while (albumToSearch != null)
@ -139,7 +139,7 @@ namespace Ombi.Core.Senders
await Task.Delay(500);
album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
albumToSearch = album.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
x.foreignAlbumId == model.ForeignAlbumId);
}
@ -165,7 +165,7 @@ namespace Ombi.Core.Senders
// Get the album id
var albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
var album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
x.foreignAlbumId == model.ForeignAlbumId);
var maxRetryCount = 10; // 5 seconds
var currentRetry = 0;
while (!albums.Any() || album == null)
@ -178,7 +178,7 @@ namespace Ombi.Core.Senders
await Task.Delay(500);
albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
x.foreignAlbumId == model.ForeignAlbumId);
}
// Get the album we want.

Loading…
Cancel
Save