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" }))); }
public Zone SaveZone(Zone Zone) { var storedItem = _ZoneRepositorý.GetById(Zone.Id); if (storedItem != null) { throw new DuplicateEntityException($"zone with Id [{Zone.Id}] already exists"); } return(_ZoneRepositorý.Save(Zone)); }
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(); } }