public ActionResult Ajouter(Excursion.Data.Zone zone, string Centre) { Excursion.Data.Zone zn = new Data.Zone(); zn.Nom = zone.Nom; zn.CodeZone = zone.CodeZone; zn.CentreID = centreRepository.FindOne(x => x.Nom == Centre).CentreID; zoneRepository.Add(zn); zoneRepository.Save(); return(RedirectToAction("Ajouter", new RouteValueDictionary( new { controller = "Excursion", action = "Ajouter" }))); }
static public void addzone(Zone zone) { using (ZoneRepository zonerepo = new ZoneRepository()) { zonerepo.context.Entry(zone.PiloteZoneObli).State = EntityState.Unchanged; if (zone.PiloteZoneOpti != null) { zonerepo.context.Entry(zone.PiloteZoneOpti).State = EntityState.Unchanged; } zonerepo.Add(zone); zonerepo.Save(); } }