static void Main(string[] args) { ICategorieRepository categorieRepository = new InMemoryCategorieRepository(); ICommuneRepository communeRepository = new InMemoryCommuneRepository(); IAdresseRepository adresseRepository = new InMemoryAdresseRepository(communeRepository); IPIRepository PIRepository = new InMemoryPIRepository(categorieRepository, adresseRepository); // Etat initial des villes foreach (var c in PIRepository.GetAll()) { Console.WriteLine(c); } Console.WriteLine("- - - - - - - -"); // Ajouter une commune var toulon = new Commune { Nom = "Toulon" }; communeRepository.Update(toulon); foreach (var c in communeRepository.GetAll()) { Console.WriteLine(c); } Console.WriteLine("- - - - - - - -"); }
private void testerLeCRUDPourLesVoies(IEntrepotPersistance entrepot) { Commune commune = new Commune(); commune.initialiserAléatoirement(); commune.définirUnEntrepotDePersistance(entrepot); commune.enregistrer(); Commune[] communes = new Commune[] { commune }; Voie voie = new Voie(); voie.initialiserAléatoirement(communes); voie.définirUnEntrepotDePersistance(entrepot); int nombreDeNumérosInitial = voie.Numéros.Count; string libelléInitial = voie.Nom.Libellé; voie.enregistrer(); Voie voieEnregistrée = entrepot.donnerLaCollection<Voie>().Single(x => x.Id == voie.Id); Assert.AreEqual(voie.Numéros.Count, voieEnregistrée.Numéros.Count); Assert.AreEqual(voie.Nom.Libellé, voieEnregistrée.Nom.Libellé); voie.initialiserAléatoirement(communes); voie.enregistrer(); Voie voieRechargée = entrepot.donnerLaCollection<Voie>().Single(x => x.Id == voie.Id); Assert.AreEqual(voie.Numéros.Count, voieRechargée.Numéros.Count); Assert.AreEqual(voie.Nom.Libellé, voieRechargée.Nom.Libellé); Assert.AreNotEqual(nombreDeNumérosInitial, voieRechargée.Numéros.Count); Assert.AreNotEqual(libelléInitial, voieRechargée.Nom.Libellé); voie.effacer(); Assert.IsFalse(entrepot.donnerLaCollection<Voie>().Any(x => x.Id == voie.Id)); commune.effacer(); }
private bool TryDeleteCommune(Commune rec) { try { using (DiabetContext dc = new DiabetContext()) { dc.Communes.Attach(rec); dc.Communes.Remove(rec); dc.SaveChanges(); } return(true); } catch (DbUpdateException ex) { var sqlExc = ex.GetBaseException() as SqlException; if (sqlExc != null && sqlExc.Number == 547) { return(false); } else { throw; } } }
public async Task <IEnumerable <Parcelle> > GetAllAsync(Commune commune) { if (commune == null) { throw new ArgumentNullException(nameof(commune)); } using (var client = new HttpClient()) { Stream compressedJson = await client.GetStreamAsync($"https://cadastre.data.gouv.fr/data/etalab-cadastre/2019-01-01/geojson/communes/{commune.CodeDepartement}/{commune.CodeInsee}/cadastre-{commune.CodeInsee}-parcelles.json.gz"); if (compressedJson == null) { throw new InvalidOperationException("Impossible de trouver les données du cadastre pour cette commune."); } using (compressedJson) using (var compressedStream = new GZipStream(compressedJson, CompressionMode.Decompress)) using (var uncompressedJson = new MemoryStream()) { await compressedStream.CopyToAsync(uncompressedJson); uncompressedJson.Position = 0; using (var sr = new StreamReader(uncompressedJson)) { string json = await sr.ReadToEndAsync(); FeatureCollection result = JsonConvert.DeserializeObject <FeatureCollection>(json); return((result?.Features ?? Enumerable.Empty <Feature>()).Select(f => new Parcelle(f)).ToList()); } } } }
private static XpoCommune MapCommune(Commune commune, UnitOfWork uow) { var xpoCommune = uow.GetObjectByKey <XpoCommune>(commune.id); xpoCommune.Name = commune.Name; return(xpoCommune); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProvinceId,Name,DE,CS")] Commune commune) { if (id != commune.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(commune); await _context.SaveChangesAsync().ConfigureAwait(false); } catch (DbUpdateConcurrencyException) { if (!ComunaExists(commune.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProvinceId"] = new SelectList(_context.Provinces, "Id", "Id", commune.ProvinceId); return(View(commune)); }
public IActionResult Ajout(int Id, string Texte, string ZipCode, float Longitude, float Latitude, int Commune) { // Création d'une nouvelle adresse si elle n'existe pas Adresse model = _repository.Single(Id); if (model == null) { model = new Adresse(); } // Hydratation des champs de l'adresse model.Texte = Texte; model.ZipCode = ZipCode; model.Longitude = Longitude; model.Latitude = Latitude; Commune commune = _communeRepo.Single(Commune); model.Commune = commune; model.Commune.DepartementId = commune.DepartementId; model.Commune.Departement = commune.Departement; // Affichage de l'adresse à ajouter _logger.LogWarning(String.Format("Commune: {0} - Departement: {1}", commune.Nom, commune.Departement?.Nom)); _logger.LogWarning(model.ToString()); _repository.Update(model); _repository.Save(); return(RedirectToAction("Index")); }
public static Area Atri_to_area(Area_date area_date) { Area result; if (area_date.Type == Typ[1])//konwersja string na inta { result = new Country(area_date); } else if (area_date.Type == Typ[2]) { result = new District(area_date); } else if (area_date.Type == Typ[3]) { result = new Province(area_date); } else if (area_date.Type == Typ[4]) { result = new Commune(area_date); } else { throw new Exception("type out posible"); } return(result); }
public ActionResult DeleteConfirmed(int id) { Commune commune = db.Communes.Find(id); db.Communes.Remove(commune); db.SaveChanges(); return(RedirectToAction("Index")); }
public List <Commune> getListeCommunesPACA() { //Liste des communes de la région _logger.LogWarning("Importing 'communes' this might take a while..."); StreamReader textReader = File.OpenText("../Isen.Dotnet.Library/Data/OpenDataLight.csv"); var csv = new CsvReader(textReader); csv.Configuration.Delimiter = ";"; List <Commune> communes = new List <Commune>(); while (csv.Read()) { var strField = csv.GetField <string>(2); if (strField == "Provence-Alpes-Côte d'Azur") { var communeField = csv.GetField <string>(8); string nomDepartement = csv.GetField <string>(5); string longitude = ""; string latitude = ""; float floatLat = -1; float floatLong = -1; try { latitude = csv.GetField <string>(11); longitude = csv.GetField <string>(12); latitude = latitude.Replace(".", ","); longitude = longitude.Replace(".", ","); floatLat = float.Parse(latitude); floatLong = float.Parse(longitude); } catch (System.Exception) { //_logger.LogWarning("Cannot get 'longitude' or 'latitude'"); } Commune commune = new Commune(); Departement departement = _departementRepository.Single(nomDepartement); if (departement == null) { departement = new Departement(); departement.Nom = nomDepartement; _departementRepository.Update(departement); _departementRepository.Save(); } commune.Nom = communeField; commune.Longitude = floatLong; commune.Latitude = floatLat; commune.Departement = departement; commune.DepartementId = departement.Id; communes.Add(commune); // _logger.LogWarning(String.Format("Commune: {0} ({1} - {2})", communeField, floatLong, floatLat)); } } return(communes); }
private int getCommuneIdByName() { Commune com = new Commune() { Name = ddlCommune.SelectedValue }; return(com.getIdByName()); }
public void TestMethod1() { Commune commune = new Commune() { Name = "El Bosque" }; Assert.AreEqual(commune.getIdByName(), 8); }
public Commune CreeCommune() { Commune result = new Commune(); result.Nom = _demandeAutilisateur.saisieNom("Nom de la commune :"); result.CodePost = _demandeAutilisateur.saisieEntier(" Code postal :"); result.NbHab = _demandeAutilisateur.saisieEntier("Combien y a-t-il d'habitants :"); Communes.Add(result); return(result); }
public EntityPerson() { Student = new Student(); Teacher = new Teacher(); CityOfBirth = new City(); CountryOfBirth = new Country(); Nationality = new Country(); ProvinceOfBirth = new Province(); CommuneOfBirth = new Commune(); }
public Commune ajouterCommune() { Commune c = new Commune(); c.Nom = _DemandeAUtilisateur.DemandeString("Quel est le nom de votre ville ?"); c.CodePost = _DemandeAUtilisateur.DemandeEntier("Quel est de code postal ?"); c.NbH = _DemandeAUtilisateur.DemandeEntier("Combie y a-t-il d'habitants ?"); return(c); }
public Commune ajouterCommune() { Commune c = new Commune(); c.Nom = _demandeALutilisateur.saisieNom("Quel est le nom de votre ville ?"); c.CodePost = _demandeALutilisateur.saisieEntier("Quel est de code postal ?"); c.NbHab = _demandeALutilisateur.saisieEntier("Combien y a-t-il d'habitants ?"); return(c); }
private dynamic GetCommune(Commune commune) { return(new { Code = commune.Code, Nom = commune.Nom, X = commune.X, Y = commune.Y, DepartementId = commune.Departement, CodeRegion = commune.CodeRegion }); }
public ActionResult Edit([Bind(Include = "commune_id,commune_name,commune_activate,commune_date,district_id")] Commune commune) { if (ModelState.IsValid) { db.Entry(commune).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.district_id = new SelectList(db.Districts, "district_id", "district_name", commune.district_id); return(View(commune)); }
public static DictionaryItemDto ToDictionaryItemDto(this Commune entity) { return(entity == null ? null : new DictionaryItemDto { Key = entity.Id.ToString(), Code = entity.CommuneCode, Value = entity.Name }); }
public async Task <IActionResult> Create([Bind("Id,ProvinceId,Name,DE,CS")] Commune commune) { if (ModelState.IsValid) { _context.Add(commune); await _context.SaveChangesAsync().ConfigureAwait(false); return(RedirectToAction(nameof(Index))); } ViewData["ProvinceId"] = new SelectList(_context.Provinces, "Id", "Id", commune.ProvinceId); return(View(commune)); }
public ActionResult Create([Bind(Include = "commune_id,commune_name,commune_activate,commune_date,district_id")] Commune commune) { if (ModelState.IsValid) { db.Communes.Add(commune); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.district_id = new SelectList(db.Districts, "district_id", "district_name", commune.district_id); return(View(commune)); }
public Commune CreeCommune() { Commune result = new Commune(); result.Nom = _demandeUtilisateur.saisieNom("Nom de la commune :"); result.CodePost = _demandeUtilisateur.saisieEntier(" Code postal :"); result.NbHab = _demandeUtilisateur.saisieEntier("nombre d'habitants :"); result.numdepart = _demandeUtilisateur.saisieEntier("Num de departement"); result.numdepart = _serviceDepartement.VerifDepart(result.numdepart); Communes.Add(result); return(result); }
public static AddressDto ToAddressDto(this Commune entity) { return(entity == null ? null : new AddressDto { Id = entity.Id, Code = entity.CommuneCode, Name = entity.Name, Type = AddressType.Ward.ToString(), }); }
public void Write(Guid id, string name, Wilaya wilaya, Commune commune) { var secteur = new Sector { id = id, Name = name, Wilaya = wilaya, Commune = commune }; _repositorySecteur.Save(secteur); }
public Commune CreerCommune() { Commune result = new Commune(); result.Nom = _demandeALutilisateur.saisieNom("Nom de la commune :"); result.CodePost = _demandeALutilisateur.saisieEntier(" Code postal :"); result.NbHab = _demandeALutilisateur.saisieEntier("nombre d'habitants :"); result.Departements = _departementService.DemandeDepartement(); Communes.Add(result); return(result); }
public Entity() { AddressCountry = new Country(); AddressProvince = new Province(); City = new City(); DistrictCommune = new Commune(); User = new User(); GeneralAccountPlan = new GeneralAccountPlan(); EntityDocumentionList = new HashSet <EntityDocumentation>(); CitizenDocument = new CitizenDocument(); VehiclesList = new HashSet <Vehicle>(); }
public CommuneViewModel(Commune commune) { if (commune == null) { return; } CountryId = commune.CountryId; DepartmentId = commune.DepartmentId; CityId = commune.CityId; Name = commune.Name; CommuneId = commune.CommuneId; }
public void Write(Guid id, string name, Wilaya wilaya, Commune commune, string adress) { var stock = new Stock(name) { id = id, Name = name, Wilaya = wilaya, Commune = commune, Adress = adress }; _repositoryStock.Save(stock); }
private void ChangeEndCommune() { if (cb_PhuongXaDen.SelectedValue != null && cb_PhuongXaDen.SelectedValue.ToString() != "0" && cbQH_Den.Items.Count > 0 && cbTinh_Den.Items.Count > 0 && G_isCompleted) { Commune objCommune = (Commune)cb_PhuongXaDen.SelectedItem; if (objCommune != null && objCommune.FK_DistrictID > 0) { G_EndDistrictSelected = objCommune.FK_DistrictID; cbQH_Den.SelectedValue = objCommune.FK_DistrictID; } } }
// GET: Communes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Commune commune = db.Communes.Find(id); if (commune == null) { return(HttpNotFound()); } return(View(commune)); }
// GET: Communes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Commune commune = db.Communes.Find(id); if (commune == null) { return(HttpNotFound()); } ViewBag.district_id = new SelectList(db.Districts, "district_id", "district_name", commune.district_id); return(View(commune)); }
private void testerLeCRUDPourLesCommunes(IEntrepotPersistance entrepot) { Commune commune = new Commune(); commune.définirUnEntrepotDePersistance(entrepot); commune.initialiserAléatoirement(); string nomInitial = commune.Nom; commune.enregistrer(); Commune communeEnregistrée = entrepot.donnerLaCollection<Commune>().Single(x => x.Id == commune.Id); Assert.AreEqual(commune.Nom, communeEnregistrée.Nom); commune.initialiserAléatoirement(); commune.enregistrer(); Commune communeRechargée = entrepot.donnerLaCollection<Commune>().Single(x => x.Id == commune.Id); Assert.AreEqual(commune.Nom, communeRechargée.Nom); Assert.AreNotEqual(nomInitial, communeRechargée.Nom); commune.effacer(); Assert.IsFalse(entrepot.donnerLaCollection<Commune>().Any(x => x.Id == commune.Id)); }