public ActionResult AjouterEnfant(int id, PersonneAjouterEnfant pae) { pae.idArbre = new PersonneServiceAPI().Donner(id).idArbre; if (ModelState.IsValid) { if (new PersonneServiceAPI().AjouterEnfant(new ParentEnfant { idEnfant = pae.machin, idParent = id })) { return(RedirectToAction("DonnerPourArbre", new { id = pae.idArbre })); } } return(View(pae)); }
public ActionResult AjouterEnfant(int id) { /* préparer la liste des enfants impossibles */ Personne p = new PersonneServiceAPI().Donner(id); IList <SelectListItem> enfants = new PersonneServiceAPI().DonnerParenteesDirectesPossibles(id) .Where(u => ((p.homme && u.idPere == null) || (!p.homme && u.idMere == null)) && u.id != p.id) .Select(j => new SelectListItem { Selected = false, Value = j.id.ToString(), Text = j.VersAffichage() }) .ToList(); ; PersonneAjouterEnfant pae = new PersonneAjouterEnfant(); pae.Parent = new PersonneServiceAPI().Donner(id).VersAffichage(); pae.enfants = enfants; pae.idArbre = p.idArbre; pae.id = p.id; return(View(pae)); }