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 user = await GetUser();
var existingSub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(x => 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) if (existingSub != null)
{ {
return; return;
@ -155,7 +155,7 @@ namespace Ombi.Core.Engine
{ {
var user = await GetUser(); var user = await GetUser();
var existingSub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(x => 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) if (existingSub != null)
{ {
await _subscriptionRepository.Delete(existingSub); await _subscriptionRepository.Delete(existingSub);

@ -24,7 +24,8 @@ namespace Ombi.Core.Rule.Rules.Request
public async Task<RuleResult> Execute(BaseRequest obj) 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) if (await _manager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser)
{ {
obj.Approved = true; obj.Approved = true;

@ -25,7 +25,8 @@ namespace Ombi.Core.Rule.Rules.Request
public async Task<RuleResult> Execute(BaseRequest obj) 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) if (await _manager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser)
return Success(); return Success();

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

@ -32,13 +32,13 @@ namespace Ombi.Core.Rule.Rules.Request
var tvContent = _plexContent.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show); var tvContent = _plexContent.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show);
// We need to do a check on the TVDBId // 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) if (anyTvDbMatches == null)
{ {
// So we do not have a TVDB Id, that really sucks. // So we do not have a TVDB Id, that really sucks.
// Let's try and match on the title and year of the show // Let's try and match on the title and year of the show
var titleAndYearMatch = await tvContent.Include(x=> x.Episodes).FirstOrDefaultAsync(x => 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()); && x.ReleaseYear == tvRequest.ReleaseYear.Year.ToString());
if (titleAndYearMatch != null) if (titleAndYearMatch != null)
{ {

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

@ -21,7 +21,7 @@ namespace Ombi.Core.Rule.Rules.Search
{ {
var obj = (SearchArtistViewModel) objec; var obj = (SearchArtistViewModel) objec;
// Check if it's in Lidarr // 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) if (result != null)
{ {
obj.Monitored = true; // It's in Lidarr so it's monitored 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 album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
var albumToSearch = album.FirstOrDefault(x => var albumToSearch = album.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase)); x.foreignAlbumId == model.ForeignAlbumId);
var maxRetryCount = 10; // 5 seconds var maxRetryCount = 10; // 5 seconds
var currentRetry = 0; var currentRetry = 0;
while (albumToSearch != null) while (albumToSearch != null)
@ -139,7 +139,7 @@ namespace Ombi.Core.Senders
await Task.Delay(500); await Task.Delay(500);
album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri); album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
albumToSearch = album.FirstOrDefault(x => 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 // Get the album id
var albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri); var albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
var album = albums.FirstOrDefault(x => var album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase)); x.foreignAlbumId == model.ForeignAlbumId);
var maxRetryCount = 10; // 5 seconds var maxRetryCount = 10; // 5 seconds
var currentRetry = 0; var currentRetry = 0;
while (!albums.Any() || album == null) while (!albums.Any() || album == null)
@ -178,7 +178,7 @@ namespace Ombi.Core.Senders
await Task.Delay(500); await Task.Delay(500);
albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri); albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
album = albums.FirstOrDefault(x => album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase)); x.foreignAlbumId == model.ForeignAlbumId);
} }
// Get the album we want. // Get the album we want.

Loading…
Cancel
Save