public ActionResult Create()
 {
     ViewBag.ad_type           = new SelectList(adtypeRepository.GetAll(), "id_ad_type", "description");
     ViewBag.id_commune        = new SelectList(communeRepository.GetAll(), "id_commune", "commune");
     ViewBag.id_devise         = new SelectList(deviseRepository.GetAll(), "id_devise", "symbole");
     ViewBag.id_category       = this.populateCategoryBySection();
     ViewBag.id_item_condition = new SelectList(condRepository.GetAll(), "id_item_condition", "item_condition");
     return(View());
 }
Example #2
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 #3
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 #6
0
        public override IActionResult Detail(int?id)
        {
            // Récupération de la liste des communes
            ViewBag.Communes     = _communeRepo.GetAll();
            ViewBag.Departements = _departementRepo.GetAll();
            _logger.LogWarning("Controller de formulaire d'ajout");

            // Pas d'id > form vide (création)
            if (id == null)
            {
                return(View());
            }
            // Récupére l'adresse et la passer à la vue
            var model = _repository.Single(id.Value);

            return(View(model));
        }
Example #7
0
        private IDictionary <string, IEnumerable <SelectListItem> > populateCommunetByDepartement()
        {
            IEnumerable <tb_departement> dep = communeRepository.GetAllDepartement();
            IEnumerable <tb_commune>     com = communeRepository.GetAll();

            IDictionary <string, IEnumerable <SelectListItem> > CommuneByDepartement = new Dictionary <string, IEnumerable <SelectListItem> >();

            foreach (var item in dep)
            {
                var comList = new List <SelectListItem>();
                foreach (var city in com.Where(c => c.id_departement == item.id_departement))
                {
                    comList.Add(new SelectListItem {
                        Value = city.id_commune.ToString(), Text = city.commune
                    });
                }
                CommuneByDepartement.Add(item.departement, comList.OrderBy(x => x.Text));
            }

            return(CommuneByDepartement);
        }
Example #8
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");
        }
Example #9
0
        public virtual JsonResult GetAllAction()
        {
            IEnumerable <Commune> allcoms = _comRepository.GetAll();

            return(Json(allcoms));
        }