public async Task When_AddingLog_Expect_LogAdded(int locationId, LocationActionEnum action) { _logService.AddLocationLog(locationId, action); await _dbContext.SaveChangesAsync(); var log = await _dbContext.Logs.FirstAsync(l => l.LocationId == locationId && l.Action == action); Assert.NotNull(log); }
public async Task Import(IEnumerable <ParsedLocationDto> parsedLocations) { var locationModels = parsedLocations .Select(p => _locationMapper.Map(p)) .ToList(); await _dbContext.Locations.AddRangeAsync(locationModels); foreach (var location in locationModels) { _logService.AddLocationLog(location.Id, LocationActionEnum.Created); } try { await _dbContext.SaveChangesAsync(); } catch (DbUpdateException) { throw new InvalidOperationException("There was an error importing location records."); } }