public override void DeleteAnnouncement(int announcementId) { Trace.Assert(Context.PersonId.HasValue); using (var uow = Update()) { var da = CreateLessonPlanDataAccess(uow); var announcement = da.GetAnnouncement(announcementId, Context.PersonId.Value); if (!AnnouncementSecurity.CanDeleteAnnouncement(announcement, Context)) { throw new ChalkableException("You can delete only your own announcement!"); } da.Delete(announcementId); uow.Commit(); } }
public void DeleteDrafts(int personId) { Trace.Assert(Context.PersonId.HasValue); if (!AnnouncementSecurity.CanDeleteAnnouncement(personId, Context)) { throw new ChalkableSecurityException(); } DoUpdate(u => { var da = CreateDataAccess(u); var conds = new AndQueryCondition { { Announcement.STATE_FIELD, AnnouncementState.Draft } }; var drafts = da.GetAnnouncements(conds, Context.PersonId.Value); da.Delete(drafts.Select(x => x.Id).ToList()); }); }
public override void DeleteAnnouncement(int announcementId) { Trace.Assert(Context.PersonId.HasValue); using (var uow = Update()) { var da = CreateSupplementalAnnouncementDataAccess(uow); var announcement = da.GetAnnouncement(announcementId, Context.PersonId.Value); new SupplementalAnnouncementRecipientDataAccess(uow).DeleteByAnnouncementId(announcementId); if (!AnnouncementSecurity.CanDeleteAnnouncement(announcement, Context)) { throw new ChalkableSecurityException(); } da.Delete(announcementId); uow.Commit(); } }
private void EnsureAdminAnnouncementDelete(Announcement announcement, UnitOfWork unitOfWork) { if (!AnnouncementSecurity.CanDeleteAnnouncement(announcement, Context)) { throw new ChalkableSecurityException(); } var assessmentId = ServiceLocator.ServiceLocatorMaster.ApplicationService.GetAssessmentId(); var assessmentAttached = new AnnouncementApplicationDataAccess(unitOfWork).Exists(new AndQueryCondition { { nameof(AnnouncementApplication.AnnouncementRef), announcement.Id }, { nameof(AnnouncementApplication.ApplicationRef), assessmentId }, { nameof(AnnouncementApplication.Active), true } }); if (assessmentAttached) { throw new AnnouncementDeleteFailedException(ChlkResources.ERR_CANT_DELETE_ITEM_WITH_ASSESSMENT, ChlkResources.ERR_TITLE_ATTACHED_ASSESSMENT); } }
public override void DeleteAnnouncement(int announcementId) { Trace.Assert(Context.PersonId.HasValue); using (var uow = Update()) { var da = CreateClassAnnouncementDataAccess(uow); var announcement = da.GetAnnouncement(announcementId, Context.PersonId.Value); if (!AnnouncementSecurity.CanDeleteAnnouncement(announcement, Context)) { throw new ChalkableSecurityException(); } if (announcement.SisActivityId.HasValue) { ConnectorLocator.ActivityConnector.DeleteActivity(announcement.SisActivityId.Value); } da.Delete(announcementId); uow.Commit(); } }