public async Task <bool> InsertArtist(Artist artist) { try { if (artist == null) { return(false); } await using var entities = new DataIngestionContext(); if (entities.Artist.Any(o => o.ArtistId == artist.ArtistId)) { return(false); } await entities.Artist.AddAsync(artist).ConfigureAwait(true); var saveChanges = await entities.SaveChangesAsync().ConfigureAwait(true); if (saveChanges > 0) { _logger.LogInformation($"Saved {artist.Name} artistCollection."); return(true); } _logger.LogInformation("Saved 0 artist."); return(false); } catch (DbUpdateException sqlex) { _logger.LogError(sqlex.Message, sqlex.Message, artist); return(false); } }
public async Task <bool> InsertCollectionMatch(CollectionMatch collectionMatch) { try { if (collectionMatch == null) { return(false); } await using var entities = new DataIngestionContext(); if (entities.CollectionMatch.Any(o => o.CollectionId == collectionMatch.CollectionId)) { return(false); } await entities.CollectionMatch.AddAsync(collectionMatch); var saveChangesAsync = await entities.SaveChangesAsync().ConfigureAwait(true); if (saveChangesAsync > 0) { _logger.LogInformation("Saved 1 collectionMatch."); return(true); } _logger.LogInformation("Saved 0 collectionMatch."); return(false); } catch (DbUpdateException sqlex) { _logger.LogError(sqlex.Message, sqlex.Message, collectionMatch); return(false); } }