public void DuplicateLessonPlan(int lessonPlanId, IList <int> classIds) { Trace.Assert(Context.SchoolYearId.HasValue); Trace.Assert(Context.PersonId.HasValue); var lessonPlan = GetLessonPlanById(lessonPlanId); // security check BaseSecurity.EnsureTeacher(Context); if (lessonPlan.IsDraft) { throw new ChalkableException("Only submited lesson plan can be duplicated"); } //get announcementApplications for copying var annApps = ServiceLocator.ApplicationSchoolService.GetAnnouncementApplicationsByAnnId(lessonPlanId, true); var appIds = annApps.Select(aa => aa.ApplicationRef).ToList(); //get only simple apps var apps = ServiceLocator.ServiceLocatorMaster.ApplicationService.GetApplicationsByIds(appIds).Where(a => !a.IsAdvanced).ToList(); annApps = annApps.Where(aa => apps.Any(a => a.Id == aa.ApplicationRef)).ToList(); using (var u = Update()) { var teachers = new ClassTeacherDataAccess(u).GetClassTeachers(lessonPlan.ClassRef, null).Select(x => x.PersonRef).ToList(); var resIds = CreateLessonPlanDataAccess(u).DuplicateLessonPlan(lessonPlanId, classIds, Context.NowSchoolYearTime); AnnouncementAttachmentService.CopyAnnouncementAttachments(lessonPlanId, teachers, resIds, u, ServiceLocator, ConnectorLocator); AnnouncementAssignedAttributeService.CopyNonStiAttributes(lessonPlanId, resIds, u, ServiceLocator, ConnectorLocator); ApplicationSchoolService.CopyAnnApplications(annApps, resIds, u); u.Commit(); } }
public void CopyToGallery(int fromAnnouncementId, int toAnnouncementId) { //AnnouncementAttachmentService.CopyAttachments(fromAnnouncementId, new List<int>(), lpGalleryId); //var annApp = ApplicationSchoolService.GetAnnouncementApplicationsByAnnIds(new List<int> { fromAnnouncementId }, true); //ApplicationSchoolService.CopyAnnApplications(lpGalleryId, annApp); //StandardService.CopyStandardsToAnnouncement(fromAnnouncementId, lpGalleryId, (int)AnnouncementTypeEnum.LessonPlan); Trace.Assert(Context.SchoolYearId.HasValue); Trace.Assert(Context.PersonId.HasValue); BaseSecurity.EnsureTeacher(Context); //get announcementApplications for copying var annApps = ServiceLocator.ApplicationSchoolService.GetAnnouncementApplicationsByAnnId(fromAnnouncementId, true); var appIds = annApps.Select(aa => aa.ApplicationRef).ToList(); //get only simple apps var apps = ServiceLocator.ServiceLocatorMaster.ApplicationService.GetApplicationsByIds(appIds).Where(a => !a.IsAdvanced).ToList(); annApps = annApps.Where(aa => apps.Any(a => a.Id == aa.ApplicationRef)).ToList(); using (var u = Update()) { AnnouncementAttachmentService.CopyAnnouncementAttachments(fromAnnouncementId, new List <int>(), new List <int> { toAnnouncementId }, u, ServiceLocator, ConnectorLocator); AnnouncementAssignedAttributeService.CopyNonStiAttributes(fromAnnouncementId, new List <int> { toAnnouncementId }, u, ServiceLocator, ConnectorLocator); ApplicationSchoolService.CopyAnnApplications(annApps, new List <int> { toAnnouncementId }, u); ServiceLocator.StandardService.CopyStandardsToAnnouncement(fromAnnouncementId, toAnnouncementId, (int)AnnouncementTypeEnum.LessonPlan); u.Commit(); } }
public override void AdjustDates(IList <int> ids, int shift, int classId) { BaseSecurity.EnsureTeacher(Context); using (var uow = Update()) { var newDates = CreateClassAnnouncementDataAccess(uow).AdjustDates(ids, shift, classId); var activityDates = ActivityDate.Create(newDates); try //Post new dates to iNow. If any conflicts terminate whole operation. { ConnectorLocator.ActivityConnector.AdjustDates(activityDates); uow.Commit(); } catch (Exception e) { uow.Rollback(); if (e.InnerException != null && e.InnerException.Message == InowErrors.ACTIVITY_SECTION_NAME_DATE_MUSTBEUNIQUE_ERROR) { throw new ChalkableException(ChlkResources.ERR_ADJUSTING_ACTIVITIES_DATE_CONFLICT); } throw; } } }
public override void AdjustDates(IList <int> ids, int shift, int classId) { BaseSecurity.EnsureTeacher(Context); //if (startDate < Context.SchoolYearStartDate || startDate > Context.SchoolYearEndDate) //throw new ChalkableException("Start date should be between school year start and end date"); DoUpdate(u => CreateLessonPlanDataAccess(u).AdjustDates(ids, shift, classId)); }