public ActionResult AjouterParent(int id, FormAjouterParent fap) { Personne p = new PersonneServiceAPI().Donner(id); fap.idArbre = p.idArbre; IEnumerable <Personne> liste = new PersonneServiceAPI().DonnerParenteesDirectesPossibles(id); if (p.idPere != null) { liste = liste.Where(j => !j.homme); } if (p.idMere != null) { liste = liste.Where(j => j.homme); } if (liste.Where(j => j.id == fap.idParent).SingleOrDefault() == null) { return(View(fap)); } if (ModelState.IsValid) { bool b = new PersonneServiceAPI().AjouterParent(new ParentEnfant { idParent = fap.idParent, idEnfant = id }); if (b) { return(RedirectToAction("DonnerPourArbre", new { id = p.idArbre })); } } return(View(fap)); }
public ActionResult Supprimer(int id) { Personne p = new PersonneServiceAPI().Donner(id); new PersonneServiceAPI().Supprimer(id); return(RedirectToAction("DonnerPourArbre", new { id = p.idArbre })); }
private static void testForm(int id) { Personne maitre = new PersonneServiceAPI().Donner(28); Personne parent = null; FormArbre fa = new FormArbre(maitre, parent); //F2ormArbre f2a = new F2ormArbre(fa); var y = "x"; }
private static void testarbre() { Personne papynorbert = new PersonneServiceAPI().Donner(28); Console.WriteLine($"prénom={papynorbert.prenom}"); PersonneDansArbreIndividuel pdai = new PersonneDansArbreIndividuel(papynorbert, int.MaxValue); string coucou = monSuperHtml(pdai); Console.WriteLine(coucou); //Console.WriteLine( monHtml(pdai)); }
public ActionResult DonnerPourArbre(int id) { IEnumerable <PersonneIndex> per = new PersonneServiceAPI().DonnerPourArbre(id).Select(j => new PersonneIndex(j, true, true)); per = per.OrderBy(j => j.nom).ThenBy(j => j.prenom).ThenBy(j => j.dateDeNaissance).ThenBy(j => j.dateDeDeces); ViewBag.Arbre = id; Arbre a = new ArbreServiceAPI().Donner(id); ViewBag.ProprietaireArbre = a.Createur().login; ViewBag.NomArbre = a.nom; Retour.InitialiseRetour("Personne", "DonnerPourArbre", id, null); return(View(per)); }
private void Machin(ActionExecutingContext contexteFiltre) { string nomControleur = (string)contexteFiltre.RouteData.Values["controller"]; int id = int.Parse((string)contexteFiltre.RouteData.Values["id"]); bool b = false; string ch = (_modele == null) ? nomControleur.ToLower() : _modele; switch (nomControleur.ToLower()) { case "role": b = new RoleServiceAPI().Donner(id) != null; break; case "personne": b = new PersonneServiceAPI().Donner(id) != null; break; case "utilisateur": b = new UtilisateurServiceAPI().Donner(id) != null; break; case "abonnement": b = new AbonnementServiceAPI().Donner(id) != null; break; case "arbre": b = new ArbreServiceAPI().Donner(id) != null; break; case "nouvelle": b = new NouvelleServiceAPI().Donner(id) != null; break; case "theme": b = new ThemeServiceAPI().Donner(id) != null; break; default: b = false; break; } if (!b) { contexteFiltre.Result = new RedirectToRouteResult (new RouteValueDictionary(new { Area = "", Controller = nomControleur, Action = "Index" })); } }
public ActionResult Modifier(int id, PersonneModification pm) { if (ModelState.IsValid) { Personne po = new PersonneServiceAPI().Donner(id); Personne p = pm.VersPersonne(); p.dateAjout = po.dateAjout; p.idArbre = po.idArbre; p.idMere = po.idMere; p.idPere = po.idPere; p.id = id; p.dateAjout = po.dateAjout; if (new PersonneServiceAPI().Modifier(id, p)) { return(RedirectToAction("DonnerPourArbre", new { id = po.idArbre })); } } return(View(pm)); }
public ActionResult Creer(PersonneCreation c) { if (ModelState.IsValid) { Personne p = c.VersPersonne(); /* contrôle arbre */ var x = SessionUtilisateur.arbres; if (SessionUtilisateur.arbres .Where(j => j.id == p.idArbre) .Count() == 1) { int i = new PersonneServiceAPI().Creer(p); if (i > 0) { return(RedirectToAction("DonnerPourArbre", new { id = c.idArbre })); } } } return(View(c)); }
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)); }
private void Machin(ActionExecutingContext contexteFiltre) { int id = 0; int idenfant = 0; IDictionary <string, object> DPar = contexteFiltre.ActionParameters; foreach (KeyValuePair <string, object> chose in DPar) { try { switch (chose.Key) { case "id": id = (int)chose.Value; break; case "idenfant": idenfant = (int)chose.Value; break; default: break; } } catch (Exception) { throw; int jj = 0; } } //string nomControleur = (string)contexteFiltre.RouteData.Values["controller"]; /*int id = int.Parse((string)contexteFiltre.RouteData.Values["id"]); * int idEnfant = int.Parse((string)contexteFiltre.RouteData.Values["idenfant"]);*/ Personne parent = new PersonneServiceAPI().Donner(id); if (parent.Enfants().Where(j => j.id == idenfant) == null) { contexteFiltre.Result = new RedirectToRouteResult (new RouteValueDictionary(new { Area = "", Controller = "Home", Action = "Index" })); } }
public ActionResult AjouterParent(int id) { FormAjouterParent fap = new FormAjouterParent(); Personne p = new PersonneServiceAPI().Donner(id); fap.idArbre = p.idArbre; IEnumerable <Personne> liste = new PersonneServiceAPI().DonnerParenteesDirectesPossibles(id); if (p.idPere != null) { liste = liste.Where(j => !j.homme); } if (p.idMere != null) { liste = liste.Where(j => j.homme); } fap.parents = liste.Select(j => new SelectListItem { Selected = false, Value = j.id.ToString(), Text = $"{j.VersAffichage()} ({j.homme.VersSexe()})" }).ToList(); return(View(fap)); }
public FormArbre(Personne p, Personne parent, int pbas = int.MaxValue) { this.fiche = ServPersonne.Fiche(p); this.parent = parent; this.maitre = p; int limite = pbas == int.MaxValue ? int.MaxValue : pbas--; IEnumerable <Personne> sescouples = new CoupleServiceAPI().Partenaires(p.id).Select(j => new PersonneServiceAPI().Donner(j)).ToList(); //if (couples == null) couples = new List<Personne>(); this.couples = new List <Personne>(); this.descendants = new List <FormArbre>(); this.dXescendants = new Dictionary <Personne, IList <FormArbre> >(); IEnumerable <Descendant> prog = new PersonneServiceAPI().DonnerLesEnfants(p.id).OrderBy(j => j.parent == null?int.MaxValue:j.parent.id).ThenBy(j => j.enfant == null?int.MaxValue:j.enfant.id); if (pbas > 0) { int memParentId = -1; IList <FormArbre> d = new List <FormArbre>(); foreach (Descendant desc in prog) { if (memParentId != (desc.parent == null?0:desc.parent.id)) { d = new List <FormArbre>(); memParentId = desc.parent == null?0:desc.parent.id; this.couples.Add(desc.parent == null?new Personne { id = 0 }:desc.parent); var y = "oo"; d.Add(new FormArbre(desc.enfant, desc.parent, limite)); dXescendants.Add(desc.parent == null?new Personne { id = 0 }:desc.parent, d); } else { d.Add(new FormArbre(desc.enfant, desc.parent, limite)); } descendants.Add(new FormArbre(new PersonneServiceAPI().Donner(desc.enfant.id), desc.parent, limite)); } IEnumerable <Personne> tempCouple = couples; foreach (Personne pp in sescouples.Where(j => !tempCouple.Select(k => k.id).Contains(j.id))) { this.couples.Add(pp); //descendants.Add(new FormArbre(pp, null, limite)); } } if (pbas == 0) { foreach (Personne pp in sescouples) { descendants.Add(new FormArbre(this.maitre, new PersonneServiceAPI().Donner(pp.id), -1)); IList <FormArbre> xx = new List <FormArbre>(); } this.couples = sescouples.ToList(); } this.fichespartenaire = new Dictionary <int, IList <string> >(); foreach (Personne pp in couples) { this.fichespartenaire.Add(pp.id, ServPersonne.Fiche(pp)); } descendants.OrderBy(j => j.maitre.id); }