Esempio n. 1
0
        public async Task AddAsync(CityDistrict cityDistrict)
        {
            var cityDistrictEntity = _mapper.Map <CityDistrict, CityDistrictEntity>(cityDistrict);

            _cityDistrictEntityDbSet.Add(cityDistrictEntity);
            await _dbContext.SaveChangesAsync();

            cityDistrict.SetRowVersion(cityDistrictEntity.RowVersion);
            _cache.Remove(CacheKeys.CityDistrictsKey);
        }
Esempio n. 2
0
        public async Task UpdateAsync(CityDistrict cityDistrict)
        {
            var cityDistrictEntity = await GetCityDistrictEntityByIdWithNameVariantEntitiesAsync(cityDistrict.Id);

            UpdateCityDistrictEntityAttributes(cityDistrictEntity, cityDistrict);
            UpdateCityDistrictNameVariantEntities(cityDistrictEntity, cityDistrict);

            _dbContext.Entry(cityDistrictEntity).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            cityDistrict.SetRowVersion(cityDistrictEntity.RowVersion);
            _cache.Remove(CacheKeys.CityDistrictsKey);
        }