Пример #1
0
        public async Task InsertRecord(InsertDataModel model)
        {
            if (!_repository.Exists(y => model.Date == y.Date && model.MarketPriceEX1 == y.MarketPriceEX1))
            {
                await _repository.Insert(model);

                OnInsertRecord?.Invoke(this, new List <InsertDataModel> {
                    model
                });
            }
        }
Пример #2
0
        public async Task <IEnumerable <InsertDataModel> > InsertMultiple(IEnumerable <InsertDataModel> models)
        {
            var existingModels = await _repository.Exists(models);

            var newModels = models.Except(existingModels);

            if (!newModels.Any())
            {
                return(newModels);
            }

            await _repository.Insert(newModels);

            OnInsertRecord?.Invoke(this, newModels);

            _cacheRepository.SetOrUpdate(newModels.OrderByDescending(x => x.Date).Take(50), CacheKeys.MarketKeys.LatestRecords);

            return(newModels);
        }