public ClassAnnouncement DropUnDropAnnouncement(int announcementId, bool drop) { Trace.Assert(Context.PersonId.HasValue); using (var uow = Update()) { var da = CreateClassAnnouncementDataAccess(uow); var ann = da.GetAnnouncement(announcementId, Context.PersonId.Value); if (!ann.IsSubmitted || ann.SisActivityId == null) { throw new ChalkableException("Announcement is not submitted yet!"); } var activity = ConnectorLocator.ActivityConnector.GetActivity(ann.SisActivityId.Value); if (activity == null) { throw new NoAnnouncementException(); } if (!AnnouncementSecurity.CanModifyAnnouncement(ann, Context)) { throw new ChalkableException("You don't have permission to drop grades"); } ann.Dropped = drop; da.Update(ann); activity.IsDropped = drop; ConnectorLocator.ActivityConnector.UpdateActivity(ann.SisActivityId.Value, activity); uow.Commit(); return(ann); } }
private bool CanAttach(AnnouncementComplex ann) { //TODO: rewrite this method later int?classId = null; if (ann.ClassAnnouncementData != null) { classId = ann.ClassAnnouncementData.ClassRef; } if (ann.LessonPlanData != null) { classId = ann.LessonPlanData.ClassRef; } return(AnnouncementSecurity.CanModifyAnnouncement(ann, Context) || (classId.HasValue && ((DemoClassService)ServiceLocator.ClassService).ClassPersonExists(classId.Value, Context.PersonId))); }
private bool CanAttach(Announcement ann) { var recipients = ServiceLocator.GetAnnouncementService(ann.Type).GetAnnouncementRecipientPersons(ann.Id, StudentFilterEnum.All); return(AnnouncementSecurity.CanModifyAnnouncement(ann, Context) || recipients.Any(p => p.Id == Context.PersonId)); }
private bool CanAttach(Announcement ann) { return(AnnouncementSecurity.CanModifyAnnouncement(ann, Context)); }