Exemplo n.º 1
0
        public async Task Save(ITransaction transaction, PersonPerCityCounter personPerCityCounter)
        {
            var session    = ((MongoSession)transaction).Session;
            var collection = MongoConnection.GetPersonPerCityCounterCollection();
            var filter     = Builders <PersonPerCityCounter> .Filter.Eq(x => x.City, personPerCityCounter.City);

            var currentDocument = await GetByCity(personPerCityCounter.City);

            personPerCityCounter.Id = currentDocument?.Id ?? GuidGenerator.GenerateGuid();

            await collection.ReplaceOneAsync(
                filter : filter,
                options : new ReplaceOptions {
                IsUpsert = true
            },
                replacement : personPerCityCounter,
                session : session);
        }
Exemplo n.º 2
0
 protected static void DecrementPerCityCounters(PersonCategoryFilter filter,
                                                PersonPerCityCounter personCategory)
 {
     personCategory.Count = Math.Max(personCategory.Count - 1, 0);
     DecrementNameCounters(filter, personCategory.PersonNameCounters);
 }
Exemplo n.º 3
0
 protected static void IncrementPerCityCounters(PersonCategoryFilter filter,
                                                PersonPerCityCounter personCategory)
 {
     personCategory.Count++;
     IncrementNameCounters(filter, personCategory.PersonNameCounters);
 }