Esempio n. 1
0
        public void AddCommunes()
        {
            if (_communeRepository.GetAll().Any())
            {
                return;
            }
            _logger.LogWarning("Adding communes");

            var communes = new List <Commune> {
            };
            string json  = File.ReadAllText("../Isen.DotNet.Library/json/communes.json");

            communes = JsonConvert.DeserializeObject <List <Commune> >(json);

            foreach (var item in communes)
            {
                item.Departement = _departementRepository.Code(item.CodeDepartement);
            }

            _communeRepository.UpdateRange(communes);
            _communeRepository.Save();

            _logger.LogWarning("Added communes");
        }