private void SyncByCompany(string url, Company company, IList <Price> prices) { var data = CsvImporter.GetCsv(url); data.RemoveAt(0); if (!data.Any()) { Logger.Warn($"No data available for company {company.Code}"); } using (var priceRepository = _priceRepositoryFactory.CreateInstance()) { var inserted = false; // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var row in data) { var currentDate = DateTime.Parse(row[0]); // ReSharper disable once InvertIf if (!prices.Any(item => item.CompanyId == company.Id && item.Date == currentDate)) { priceRepository.Insert(PriceConverter.Convert(row, company)); inserted = true; } } if (inserted) { priceRepository.Save(); } } }