Exemplo n.º 1
0
        public ActionResult ProfilEdit(string login = "", string adminToken = null)
        {
            Profil currentProfil  = dalProfil.getProfil(HttpContext.User.Identity.Name);
            Profil selectedProfil = dalProfil.getProfil(login);

            if (selectedProfil != null)
            {
                List <string> adminsToken = dalProfil.GetAdminsToken();
                if (!currentProfil.login.Equals(selectedProfil.login) && !adminsToken.Contains(adminToken))
                {
                    ModelState.AddModelError("Profil", "Vous n'avez pas accès à cette page.");
                    return(Redirect("/"));
                }
                else
                {
                    if (adminsToken.Contains(adminToken))
                    {
                        var listItem = new List <SelectListItem>
                        {
                            new SelectListItem {
                                Text = "Juge", Value = ProfilDal.JUGE
                            },
                            new SelectListItem {
                                Text = "Administrateur", Value = ProfilDal.ADMIN
                            },
                            new SelectListItem {
                                Text = "Arbitre", Value = ProfilDal.ARBITRE
                            }
                        };
                        ViewBag.listRole = listItem;
                    }
                    Juge juge = dalJuge.GetJugeFromProfil(selectedProfil);
                    if (juge != null)
                    {
                        ViewBag.personne = dalJuge.GetPersonneFromJuge(juge);
                    }
                    ViewBag.profil = selectedProfil;
                }
            }
            else
            {
                ViewBag.profil = currentProfil;
            }
            return(View());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialise une nouvelle instance de la classe <see cref="TestsJuge"/>.
 /// </summary>
 public TestsJuge()
 {
     this.juge = new Juge();
 }
Exemplo n.º 3
0
        public ActionResult ProfilEdit(Profil profil, Personne personne, int idProfil = -1, int idPersonne = -1, string mailPersonne = "", string mailValid = "", string passwordValid = "")
        {
            if (profil != null && idProfil != -1)
            {
                Profil profilToUpdate = dalProfil.getProfil(idProfil);
                bool   validMail      = mailValid.Equals(profil.mail);
                bool   validPassword  = passwordValid.Equals(profil.password);
                if (profil.login != null || !"".Equals(profil.login))
                {
                    profilToUpdate.login = profil.login;
                }
                if (validPassword && (profil.password != null || !"".Equals(profil.password)))
                {
                    profilToUpdate.password = profil.password;
                }
                if (validMail && (profil.mail != null || !"".Equals(profil.mail)))
                {
                    profilToUpdate.mail = profil.mail;
                }
                if (profil.commentaire != null || !"".Equals(profil.commentaire))
                {
                    profilToUpdate.commentaire = profil.commentaire;
                }
                if (profil.role != null || !"".Equals(profil.role))
                {
                    profilToUpdate.role = profil.role;
                }
                if (personne != null && !ProfilDal.ADMIN.Equals(profil.role))
                {
                    personne.mail = mailPersonne;
                    if (idPersonne != -1)
                    {
                        Personne personneToUpdate = dalPersonne.Get(idPersonne);
                        if (personne.nom != null || !"".Equals(personne.nom))
                        {
                            personneToUpdate.nom = personne.nom;
                        }
                        if (personne.prenom != null || !"".Equals(personne.prenom))
                        {
                            personneToUpdate.prenom = personne.prenom;
                        }
                        if (personne.dateNaissance != null || !"".Equals(personne.dateNaissance))
                        {
                            personneToUpdate.dateNaissance = personne.dateNaissance;
                        }
                        if (personne.telFixe != null || !"".Equals(personne.telFixe))
                        {
                            personneToUpdate.telFixe = personne.telFixe;
                        }
                        if (personne.telPortable != null || !"".Equals(personne.telPortable))
                        {
                            personneToUpdate.telPortable = personne.telPortable;
                        }
                        if (personne.mail != null || !"".Equals(personne.mail))
                        {
                            personneToUpdate.mail = personne.mail;
                        }
                    }
                    else
                    {
                        Personne personneToAdd = new Personne
                        {
                            nom           = personne.nom,
                            prenom        = personne.prenom,
                            dateNaissance = personne.dateNaissance,
                            telFixe       = personne.telFixe,
                            telPortable   = personne.telPortable,
                            mail          = mailPersonne
                        };
                        dalPersonne.Add(personneToAdd);

                        Juge juge = new Juge
                        {
                            id_Personne = personneToAdd.id,
                            id_Profil   = profilToUpdate.id
                        };
                        dalJuge.Add(juge);
                    }
                }
                dalProfil.UpdateProfil();
            }
            return(Redirect("/"));
        }