public ActionResult Ajouter(Excursion.Data.Region region, string Zone) { Excursion.Data.Region rg = new Data.Region(); rg.Nom = region.Nom; rg.CodeRegion = region.CodeRegion; rg.ZoneID = zoneRepository.FindOne(x => x.Nom == Zone).ZoneID; regionRepository.Add(rg); regionRepository.Save(); return(RedirectToAction("Ajouter", new RouteValueDictionary( new { controller = "Excursion", action = "Ajouter" }))); }
public ActionResult Ajouter(Excursion.Portail.Models.Prix prix, string Device, List <string> Zones) { Excursion.Data.Prix pr = new Data.Prix(); pr.DateDebut = prix.DateDebutP; pr.DateFin = prix.DateFinP; pr.PrixAdulte = prix.PrixAdulte; pr.PrixEnfant = prix.PrixEnfant; pr.PrixBebe = prix.PrixBebe; pr.Monnaie = Device; prixRepository.Add(pr); prixRepository.Save(); foreach (string zone in Zones) { ZonePrix zp = new ZonePrix(); zp.PrixID = pr.PrixID; zp.ZoneID = zoneRepository.FindOne(x => x.Nom == zone).ZoneID; zonePrixRepository.Add(zp); zonePrixRepository.Save(); } return(RedirectToAction("Ajouter", new RouteValueDictionary( new { controller = "Excursion", action = "Ajouter" }))); }