Exemplo n.º 1
0
        public async Task <ValidationResult> ValidData(IEnumerable <string> data)
        {
            var result = new ValidationResult();

            foreach (var record in data.RemoveDuplicates().Select((value, i) => new { i, value }))
            {
                if (record.value.IsValid(out var date, out var marketPrice))
                {
                    var validRecord = new InsertDataModel
                    {
                        Date           = date,
                        MarketPriceEX1 = marketPrice
                    };
                    OnValidRecord?.Invoke(this, new ValidRecordEventArgs
                    {
                        InsertData = validRecord,
                        Row        = record.i
                    });
                    result.ValidRecord.Add(validRecord);
                }
                else
                {
                    result.MalformedRecordLine.Add(record.i);
                    OnMalformedRecord?.Invoke(this, record.i);
                }
            }

            return(await Task.FromResult(result));
        }
 public bool IsValidRecord(BacktraceDatabaseRecord record)
 {
     if (OnValidRecord != null)
     {
         return(OnValidRecord.Invoke(record));
     }
     return(false);
 }
 public bool IsValidRecord(BacktraceDatabaseRecord record)
 {
     return(OnValidRecord?.Invoke(record) ?? true);
 }