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); } }
private CollectionMatch GetCollectionMatchRow(string row) { try { var replace = row.Replace("\u0002", ""); var strings = replace.Split('\x01'); var collectionMatch = new CollectionMatch { ExportDate = strings.ElementAtOrDefault(0) != null ? strings[0] : string.Empty, CollectionId = long.Parse(strings[1]), Upc = strings.ElementAtOrDefault(2) != null ? strings[2] : string.Empty, Grid = strings.ElementAtOrDefault(3) != null ? strings[3] : string.Empty, AmgAlbumId = strings.ElementAtOrDefault(4) != null ? strings[4] : string.Empty }; return(collectionMatch); } catch (IndexOutOfRangeException) { return(null); } }