Ejemplo n.º 1
0
        public static bool ADesInscriptionsMentorat(this System.Security.Principal.IPrincipal principal)
        {
            if (principal.Identity.IsAuthenticated)
            {
                using (var db = new ApplicationDbContext())
                {
                    ApplicationUser monUser = db.Users.Where(w => w.UserName == principal.Identity.Name.ToString()).FirstOrDefault();

                    if (monUser != null)
                    {
                        MentoratInscription inscription = db.MentoratInscription.Where(w => w.Mentore.No_Mentore.Contains(monUser.Id)).FirstOrDefault();
                        if (inscription != null)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        }//fin class

        private static bool ValiderSiEstLeMentor(ActionExecutingContext actionContext)
        {
            string noMentore = "";
            string noAnnee = "";

            foreach (var key in actionContext.ActionArguments.Keys)
            {
                if (actionContext.ActionArguments[key] != null)
                {
                    switch (key.ToLower())
                    {
                        case "nomentore":
                            noMentore = actionContext.ActionArguments[key].ToString();
                            break;
                        case "noannee":
                            noAnnee = actionContext.ActionArguments[key].ToString();                           
                            break;
                        default:
                            break;
                    }
                }

            }

            if(noMentore !="" && noAnnee != "")
            {
                using (var db = new ApplicationDbContext())
                {
                    string userId = actionContext.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); // string  userId = HttpContext.Current.User.Id();

                    int annee = int.Parse(noAnnee);

                    MentoratInscription inscription=  db.MentoratInscription.FirstOrDefault(f => f.Mentore.No_Mentore == noMentore && f.Annee == annee);
                    
                    if(inscription!= null)
                    {
                        if(inscription.Mentor != null)
                        {
                            if(inscription.Mentor.NoMentor == userId)
                            {
                                return true;
                            }
                        }
                    }
                }
             }

            return false;
        }
Ejemplo n.º 3
0
        private List <Mentore> ObtenirListeMentore(string iNoMentor)
        {
            var lstDuMentor    = new List <Mentore>();
            var lstAutreMentor = new List <Mentore>();

            foreach (Mentore monMentore in db.Mentores.ToList().OrderBy(c => c.Prenom_Mentore).ThenBy(c => c.Nom_Mentore))
            {
                MentoratInscription inscription = monMentore.Inscriptions.Where(w => w.Mentor.NoMentor != "1" || w.Mentore.No_Mentore == "F1490F96-566E-4440-ABE1-11660546E914" || w.Mentore.No_Mentore == "FB0660F1-0EE6-4CA6-9D31-BA74B02CE204").OrderByDescending(o => o.Annee).FirstOrDefault(); //la dernière inscription
                Mentor mentorTmp;

                if (inscription != null)
                {
                    mentorTmp = inscription.Mentor;

                    if (mentorTmp != null && mentorTmp.NoMentor == "1" && monMentore.No_Mentore != "F1490F96-566E-4440-ABE1-11660546E914")
                    {
                        //pour filtrer les mentorés qui n'ont pas de mentor
                        mentorTmp = null;
                    }
                }
                else
                {
                    //mentorTmp = db.Mentors.OrderBy(o => o.NoMentor).First();
                    if (monMentore.No_Mentore == "1" || monMentore.No_Mentore == "FB0660F1-0EE6-4CA6-9D31-BA74B02CE204")
                    {
                        mentorTmp = db.Mentors.OrderBy(o => o.NoMentor).First();
                    }
                    else
                    {
                        mentorTmp = null;
                    }
                }

                if (mentorTmp != null)
                {
                    //on ne veut pas des mentorés pas encore assignés
                    var mentoreTmp = new Mentore
                    {
                        No_Mentore     = monMentore.No_Mentore,
                        Prenom_Mentore = monMentore.Prenom_Mentore,
                        Nom_Mentore    = monMentore.Nom_Mentore,
                        MentorMentore  = mentorTmp
                    };
                    if (mentoreTmp.MentorMentore.NoMentor == iNoMentor || mentoreTmp.MentorMentore.NoMentor == "1") //est le mentor ou est le mentore "sélectionner un mentoré.."
                    {
                        lstDuMentor.Add(mentoreTmp);
                    }
                    else
                    {
                        mentoreTmp.Nom_Mentore += " (" + mentoreTmp.MentorMentore.NomCompletMentor + ")";
                        lstAutreMentor.Add(mentoreTmp);
                    }
                }
            }



            if (lstAutreMentor != null)
            {
                lstDuMentor.AddRange(lstAutreMentor);
            }

            return(lstDuMentor);
        }