Ejemplo n.º 1
0
        public AnnouncementDetails Create(ClassAnnouncementType classAnnType, int classId, DateTime expiresDate)
        {
            Trace.Assert(Context.SchoolLocalId.HasValue);
            Trace.Assert(Context.PersonId.HasValue);

            if (!AnnouncementSecurity.CanCreateAnnouncement(Context))
            {
                throw new ChalkableSecurityException();
            }

            using (var uow = Update())
            {
                var annDa = CreateClassAnnouncementDataAccess(uow);
                var res   = annDa.Create(classAnnType.Id, classId, Context.NowSchoolTime, expiresDate, Context.PersonId.Value);
                uow.Commit();
                var sy = new SchoolYearDataAccess(uow).GetByDate(Context.NowSchoolYearTime, Context.SchoolLocalId.Value);
                res = InternalGetDetails(annDa, res.Id);
                var classAnnData = res.ClassAnnouncementData;
                if (classAnnData.ClassAnnouncementTypeRef.HasValue)
                {
                    classAnnData.ClassAnnouncementTypeName = classAnnType.Name;
                    classAnnData.ChalkableAnnouncementType = classAnnType.ChalkableAnnouncementTypeRef;
                }
                return(res);
            }
        }
Ejemplo n.º 2
0
 public SchoolYear GetCurrentSchoolYear()
 {
     Trace.Assert(Context.SchoolLocalId.HasValue);
     using (var uow = Read())
     {
         var da = new SchoolYearDataAccess(uow);
         if (Context.SchoolYearId.HasValue)
         {
             return(da.GetById(Context.SchoolYearId.Value));
         }
         var nowDate = Context.NowSchoolYearTime.Date;
         var res     = da.GetByDate(nowDate, Context.SchoolLocalId.Value);
         return(res ?? da.GetLast(nowDate, Context.SchoolLocalId.Value));
     }
 }
Ejemplo n.º 3
0
        public Homeroom GetStudentHomeroomOrNull(int studentId, int schoolYearId)
        {
            using (var uow = Read())
            {
                var studentSchoolYear = new SchoolYearDataAccess(uow).GetStudentSchoolYear(studentId, schoolYearId);
                if (studentSchoolYear?.HomeroomRef == null)
                {
                    return(null);
                }

                var homeroom = new DataAccessBase <Homeroom, int>(uow).GetById(studentSchoolYear.HomeroomRef.Value);
                if (homeroom?.TeacherRef == null)
                {
                    return(homeroom);
                }

                homeroom.Teacher = new PersonDataAccess(uow).GetById(homeroom.TeacherRef.Value);

                return(homeroom);
            }
        }