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

            var m_commune = JsonConvert.DeserializeObject <dynamic>(File.ReadAllText("../Isen.DotNet.Library/Commune.json"));
            var communes  = new List <Commune> {
            };
            String dept;

            foreach (var m_com in m_commune.Communes)
            {
                dept = m_com.nom_département.ToString();
                communes.Add(new Commune {
                    Name        = m_com.nom_commune.ToString(),
                    Departement = _departRepository.Single(dept),
                    Latitude    = m_com.latitude.ToString(),
                    Longitude   = m_com.longitude.ToString()
                });
            }
            _communeRepository.UpdateRange(communes);
            _communeRepository.Save();

            _logger.LogWarning("Added communes");
        }
Example #2
0
        public void AddCommunes()
        {
            if (_communeRepository.GetAll().Any())
            {
                return;
            }
            ;

            var communes = new List <Commune>
            {
                new Commune
                {
                    Nom       = "Toulon",
                    Lattitude = 43.116667,
                    Longitude = 5.933333
                },
                new Commune
                {
                    Nom       = "Le Pradet",
                    Lattitude = 43.0983906,
                    Longitude = 6.0038674
                },
            };

            _communeRepository.UpdateRange(communes);
            _communeRepository.Save();
        }
        public void AddCommune()
        {
            if (_communeRepository.GetAll().Any())
            {
                return;
            }
            _logger.LogInformation("Adding Communes");
            string fileName = "CommunesPaca.csv";
            string path1    = @"SeedData";
            string path;

            path = Path.GetFullPath(path1) + "\\" + fileName;
            using (var sr = new StreamReader(path))
            {
                var reader = new CsvReader(sr);
                reader.Configuration.MissingFieldFound = null;

                reader.Configuration.RegisterClassMap <CommuneMap>();
                reader.Read();
                reader.ReadHeader();
                IEnumerable <commune> communes = reader.GetRecords <commune>();


                _communeRepository.UpdateRange(communes);
                try{
                    _communeRepository.Save();
                }catch (DbUpdateConcurrencyException ex)
                {
                    foreach (var entry in ex.Entries)
                    {
                        if (entry.Entity is commune)
                        {
                            var proposedValues = entry.CurrentValues;
                            var databaseValues = entry.GetDatabaseValues();

                            foreach (var property in proposedValues.Properties)
                            {
                                var proposedValue = proposedValues[property];
                                var databaseValue = databaseValues[property];
                            }
                            entry.OriginalValues.SetValues(databaseValues);
                        }
                        else
                        {
                            throw new System.NotSupportedException(
                                      "Don't know how to handle concurency conflicts for "
                                      + entry.Metadata.Name
                                      );
                        }
                    }
                }
            }
        }
        public void AddCommunes()
        {
            if (_communeRepository.GetAll().Any())
            {
                return;
            }
            _logger.LogWarning("Adding communes");
            List <Commune> communes = getListeCommunesPACA();

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

            _logger.LogWarning("Added communes");
        }
Example #5
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");
        }