Ejemplo n.º 1
0
        internal static List <StudentGrade> StaticGetGrades(Guid studentGuid, DateTime startDate, DateTime endDate)
        {
            using (var db = new SchoolContext())
            {
                var studentClasses = EnrollementManager.GetStudentInscriptions(studentGuid, startDate, endDate).Select(c => c.ClasseGuid);

                var controls = new List <Study>();
                foreach (var classe in studentClasses)
                {
                    controls.AddRange(
                        db.Studies.Where(c => !c.IsDeleted && c.ClasseGuid == classe && (c.Type == CoursTypes.Control || c.Type == CoursTypes.Examen || c.Type == CoursTypes.Test || c.Type == CoursTypes.Devoir || c.Type == CoursTypes.Composition) && (
                                             c.StartDate >= startDate &&
                                             c.StartDate <= endDate
                                             )));
                }

                var grades = new List <StudentGrade>();
                foreach (var examGuid in controls.OrderBy(c => c.StartDate).Select(c => c.StudyGuid).ToList())
                {
                    var corrected = db.StudentGrades.FirstOrDefault(g => g.CoursGuid == examGuid);
                    if (corrected != null)
                    {
                        grades.Add(corrected);
                    }
                }
                return(grades);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// List des periodes dont un etudiant est Inscris
        /// </summary>
        /// <param name="studentGuid"></param>
        /// <returns></returns>
        public Dictionary <string, string> GetStudentPeriodesScolaires(Guid studentGuid)
        {
            var periodes = new List <SchoolPeriod>();

            foreach (
                var anScoGuid in
                EnrollementManager.GetStudentInscriptions(studentGuid)
                .Select(i => i.SchoolYearGuid)
                .ToList())
            {
                periodes.AddRange(GetPeriodeScolaires(anScoGuid).ToList());
            }

            return(periodes.Where(p => p.StartDate <= DateTime.Today).OrderBy(a => a.StartDate)
                   .ToDictionary(a => a.Name + " (" + a.StartDate.GetValueOrDefault().Year + ")", a => a.SchoolPeriodGuid.ToString()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// La liste des messages d'une personne
        /// </summary>
        /// <param name="personGuid"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <param name="maxResult"></param>
        /// <returns></returns>
        public List <DataCard> GetPersonMessages(Guid personGuid, DateTime?fromDate = null, DateTime?toDate = null, int maxResult = 20)
        {
            using (var db = new SchoolContext())
            {
                if (fromDate == null || toDate == null)
                {
                    fromDate = DateTime.Today;
                    toDate   = DateTime.Today.AddDays(1);
                }

                var mesMessages = new List <Conversation>();

                mesMessages.AddRange(db.Conversations.Include(m => m.Sender).Where(m => (m.RecipientGuid == personGuid || m.SenderGuid == personGuid) && !m.IsDeleted && (
                                                                                       m.DateAdded >= fromDate &&
                                                                                       m.DateAdded <= toDate
                                                                                       )));
                var isStaff = db.Staffs.Any(s => s.Person.PersonGuid == personGuid);

                if (isStaff)
                {
                    mesMessages.AddRange(db.Conversations.Include(m => m.Sender).Where(m => m.MessageType == MessageType.ToStaffs && !m.IsDeleted && (
                                                                                           m.DateAdded >= fromDate &&
                                                                                           m.DateAdded <= toDate
                                                                                           )));
                }
                else
                {
                    mesMessages.AddRange(
                        db.Conversations.Include(m => m.Sender).Where(m => m.MessageType == MessageType.ToStudents && !m.IsDeleted && (
                                                                          m.DateAdded >= fromDate &&
                                                                          m.DateAdded <= toDate
                                                                          )));

                    var student = db.Students.FirstOrDefault(s => s.Person.PersonGuid == personGuid);
                    if (student == null)
                    {
                        return(mesMessages.Distinct()
                               .OrderByDescending(m => m.DateAdded)
                               .Take(maxResult)
                               .ToList()
                               .Select(m => new DataCard(m, personGuid))
                               .ToList());
                    }
                    var mesClasses =
                        EnrollementManager.GetStudentInscriptions(
                            student.StudentGuid, fromDate, toDate).Select(i => i.ClasseGuid);
                    foreach (var classeGuid in mesClasses)
                    {
                        mesMessages.AddRange(
                            db.Conversations.Include(m => m.Sender).Where(
                                m =>
                                m.MessageType == MessageType.ToClasse && m.RecipientGuid == classeGuid &&
                                !m.IsDeleted && (
                                    m.DateAdded >= fromDate &&
                                    m.DateAdded <= toDate
                                    )));
                    }
                }
                return(mesMessages.Distinct()
                       .OrderByDescending(m => m.DateAdded)
                       .Take(maxResult)
                       .ToList()
                       .Select(m => new DataCard(m, personGuid))
                       .ToList());
            }
        }