public static CsvAgregationsByCountry From(RegisteredCredential credential)
 {
     return(new CsvAgregationsByCountry()
     {
         type = "point",
         name_es = string.Empty,
         name_pt = string.Empty,
         name_en = string.Empty,
         lat = credential.Lat,
         lon = credential.Lon,
         usersCount = 1,
         transactionCount = 1, //TODO
         noSymptomsCount = credential.HasNoSymptoms.GetValueOrDefault() ? 1 : 0,
         symptomsCount = credential.HasSymptoms.GetValueOrDefault() ? 1 : 0,
         healthyCount = credential.HasNoSymptoms.GetValueOrDefault() ? 1 : 0, //TODO
         feverCount = credential.HasFever.GetValueOrDefault() ? 1 : 0,
         coughCount = credential.HasCought.GetValueOrDefault() ? 1 : 0,
         breathingIssuesCount = credential.HasBreathingIssues.GetValueOrDefault() ? 1 : 0,
         lossSmellCount = credential.HasLossSmell.GetValueOrDefault() ? 1 : 0,
         headacheCount = credential.HasHeadache.GetValueOrDefault() ? 1 : 0,
         musclePainCount = credential.HasMusclePain.GetValueOrDefault() ? 1 : 0,
         soreThroatCount = credential.HasSoreThroat.GetValueOrDefault() ? 1 : 0,
         infectedCount = credential.CredentialType == CredentialType.Infection ? 1 : 0,
         recoveryCount = credential.CredentialType == CredentialType.Recovery ? 1 : 0,
         confinedCount = credential.CredentialType == CredentialType.Confinement ? 1 : 0,
         confinementInterruptionCount = credential.CredentialType == CredentialType.Interruption ? 1 : 0,
         purchaseFoodCount = credential.Reason == InterruptionReason.Food ? 1 : 0,
         workCount = credential.Reason == InterruptionReason.Work ? 1 : 0,
         medicinesCount = credential.Reason == InterruptionReason.Medicines ? 1 : 0,
         doctorCount = credential.Reason == InterruptionReason.Doctor ? 1 : 0,
         movingCount = credential.Reason == InterruptionReason.Moving ? 1 : 0,
         assistCount = credential.Reason == InterruptionReason.Assist ? 1 : 0,
         financialCount = credential.Reason == InterruptionReason.Financial ? 1 : 0,
         forceCount = credential.Reason == InterruptionReason.Force ? 1 : 0,
         petsCount = credential.Reason == InterruptionReason.Pets ? 1 : 0,
         maleCount = credential.Sex == Sex.Male ? 1 : 0,
         femaleCount = credential.Sex == Sex.Female ? 1 : 0,
         otherSexCount = credential.Sex == Sex.Other ? 1 : 0,
         unspecifiedSexCount = credential.Sex == Sex.Unspecified ? 1 : 0,
         age = credential.Age,
         form1318Count = credential.Age <= 18 ? 1 : 0,
         form1930Count = credential.Age > 18 || credential.Age <= 30 ? 1 : 0,
         form3140Count = credential.Age > 30 || credential.Age <= 40 ? 1 : 0,
         form4165Count = credential.Age > 40 || credential.Age <= 65 ? 1 : 0,
         form66Count = credential.Age > 65 ? 1 : 0,
         hash = credential.HashId,
         subjectId = credential.SubjectHashId
     });
 }
Пример #2
0
        public async Task ImportAsync(EthEventDTO ethEvent)
        {
            var credential = RegisteredCredential.From(ethEvent);

            try
            {
                var country = await this.covidUnitOfWork.Countries.SingleOrDefaultAsync(x => x.Geom.Contains(credential.Location));

                var state = await this.covidUnitOfWork.States.SingleOrDefaultAsync(x => x.Geom.Contains(credential.Location));

                credential.CountryGid = country.Gid;
                credential.StateGid   = state.Gid;
                await covidUnitOfWork.Credentials.AddAsync(credential);

                await covidUnitOfWork.CommitAsync();
            }
            catch (Exception e)
            {
                throw new Exception($"Error on EthEvent transaction hash: {ethEvent.TransactionHash}", e);
            }
        }