Beispiel #1
0
        private void Machin(ActionExecutingContext contexteFiltre)
        {
            //IDictionary<string, object> DPar = contexteFiltre.ActionParameters;
            //string nomControleur = (string)contexteFiltre.RouteData.Values["controller"];
            int id = int.Parse((string)contexteFiltre.RouteData.Values["id"]);

            switch (_modele)
            {
            case "arbre":
                Arbre a = new ArbreServiceAPI().Donner(id);
                if (a.idCreateur != SessionUtilisateur.Utilisateur.id)
                {
                    contexteFiltre.Result = new RedirectToRouteResult
                                                (new RouteValueDictionary(new { Area = "", Controller = "Home", Action = "Index" }));
                }
                break;

            case "personne":
                if (new ArbreServiceAPI().Donner(new PersonneServiceAPI().Donner(id).idArbre).idCreateur != SessionUtilisateur.Utilisateur.id)
                {
                    contexteFiltre.Result = new RedirectToRouteResult
                                                (new RouteValueDictionary(new { Area = "", Controller = "Home", Action = "Index" }));
                }
                break;

            default:
                contexteFiltre.Result = new RedirectToRouteResult
                                            (new RouteValueDictionary(new { Area = "", Controller = "Home", Action = "Index" }));
                break;
            }
        }
        public ActionResult Index()
        {
            ArbreServiceAPI          rs = new ArbreServiceAPI();
            IEnumerable <ArbreIndex> ri = rs.DonnerParUtilisateur(SessionUtilisateur.Utilisateur.id).Select(m => new ArbreIndex(m));

            return(View(ri));
        }
        public ActionResult Modifier(int id)
        {
            ArbreServiceAPI   rs = new ArbreServiceAPI();
            ArbreModification r  = new ArbreModification(rs.Donner(id));

            return(View(r));
        }
        /*pas bloqué*/
        public ActionResult Desactiver(int id)
        {
            ArbreServiceAPI rsa = new ArbreServiceAPI();
            bool            b   = rsa.Desactiver(id);

            return(RedirectToAction("Index"));
        }
        public ActionResult Supprimer(int id)
        {
            ArbreServiceAPI rsa = new ArbreServiceAPI();
            ArbreDetails    r   = new ArbreDetails(rsa.Donner(id));

            return(View(r));
        }
        public ActionResult Details(int id)
        {
            ArbreServiceAPI rsa = new ArbreServiceAPI();
            Arbre           r   = rsa.Donner(id);
            ArbreDetails    rd  = new ArbreDetails(r);

            return(View(rd));
        }
        public ActionResult ListerTout()
        {
            ArbreServiceAPI          asa = new ArbreServiceAPI();
            IEnumerable <ArbreIndex> ai  = asa.Donner().Select(j => { ArbreIndex a   = new ArbreIndex(j);
                                                                      a.proprietaire = new UtilisateurServiceAPI().Donner(j.idCreateur).login;
                                                                      a.blocage      = j.idBlocage == null ? "xxx" : new BlocageServiceAPI().Donner((int)j.idBlocage).nom;
                                                                      return(a); });

            return(View(ai));
        }
Beispiel #8
0
        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)
        {
            //IDictionary<string, object> DPar = contexteFiltre.ActionParameters;
            //string nomControleur = (string)contexteFiltre.RouteData.Values["controller"];
            int   id = int.Parse((string)contexteFiltre.RouteData.Values["id"]);
            Arbre a  = new ArbreServiceAPI().Donner(id);

            if (a.NombreDePersonnes() != 0)
            {
                contexteFiltre.Result = new RedirectToRouteResult
                                            (new RouteValueDictionary(new { Area = "", Controller = "Home", Action = "Index" }));
            }
        }
 public ActionResult Supprimer(int id, ArbreDetails r)
 {
     if (ModelState.IsValid)
     {
         ArbreServiceAPI rsa = new ArbreServiceAPI();
         Arbre           a   = rsa.Donner(id);
         bool            b   = rsa.Supprimer(id);
         if (b)
         {
             SessionUtilisateur.arbres.Remove(a);
             return(RedirectToAction("Index"));
         }
     }
     return(View(r));
 }
        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, ArbreModification rm)
        {
            if (ModelState.IsValid)
            {
                ArbreServiceAPI rsa = new ArbreServiceAPI();
                Arbre           a   = rsa.Donner(id);

                Arbre r = rm.VersArbre();
                r.id = a.id;

                bool b = rsa.Modifier(id, r);
                if (b)
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(View(rm));
        }
        public ActionResult Creer(ArbreCreation e)
        {
            if (ModelState.IsValid)
            {
                ArbreServiceAPI rsa = new ArbreServiceAPI();
                Arbre           a   = e.VersArbre();
                /* init */
                a.idCreateur = SessionUtilisateur.Utilisateur.id;

                /****/
                int i = rsa.Creer(a);
                if (i > 0)
                {
                    SessionUtilisateur.arbres.Add(new ArbreServiceAPI().Donner(i));
                    return(RedirectToAction("Index"));
                }
            }
            return(View(e));
        }
        public ActionResult Bloquer(int id, FormBlocageArbre e)
        {
            if (ModelState.IsValid)
            {
                BlocageArbre ba = new BlocageArbre();
                ba.id         = id;
                ba.idBloqueur = SessionUtilisateur.Utilisateur.id;

                /*object oo = e.blocages.SelectedValue;
                 * oo = e.blocageChoisi;
                 *
                 *
                 * ba.idBlocage = (int)new BlocageServiceAPI().DonnerParNom((string)oo);*/
                ba.idBlocage = e.idBlocage;

                bool b = new ArbreServiceAPI().Bloquer(ba);
                if (b)
                {
                    return(RedirectToAction("ListerTout"));
                }
            }
            return(View(e));
        }