public void UpdateAnnouncementApplicationMeta(int announcementApplicationId, AnnouncementTypeEnum announcementType, string text, string imageUrl, string description)
        {
            Trace.Assert(Context.SchoolLocalId.HasValue);
            Trace.Assert(Context.PersonId.HasValue);
            using (var uow = Update())
            {
                var da  = new AnnouncementApplicationDataAccess(uow);
                var aa  = da.GetById(announcementApplicationId);
                var ann = ServiceLocator.GetAnnouncementService(announcementType).GetAnnouncementById(aa.AnnouncementRef);
                if (!ann.IsOwner && Context.Role != CoreRoles.DISTRICT_ADMIN_ROLE)
                {
                    throw new ChalkableSecurityException(ChlkResources.ERR_SECURITY_EXCEPTION);
                }
                aa.Text = text;

                if (string.IsNullOrWhiteSpace(imageUrl) || !Uri.IsWellFormedUriString(imageUrl, UriKind.Absolute))
                {
                    imageUrl = null;
                }

                aa.ImageUrl    = imageUrl;
                aa.Description = description;
                da.Update(aa);
                uow.Commit();
            }
        }
        public void AttachAppToAnnouncement(int announcementAppId, AnnouncementTypeEnum announcementType)
        {
            Trace.Assert(Context.SchoolLocalId.HasValue);
            Trace.Assert(Context.PersonId.HasValue);
            using (var uow = Update())
            {
                var da = new AnnouncementApplicationDataAccess(uow);
                var aa = da.GetById(announcementAppId);

                var ann = ServiceLocator.GetAnnouncementService(announcementType).GetAnnouncementById(aa.AnnouncementRef);
                if (!ann.IsOwner && Context.Role != CoreRoles.DISTRICT_ADMIN_ROLE)
                {
                    throw new ChalkableSecurityException(ChlkResources.ERR_SECURITY_EXCEPTION);
                }
                aa.Active = true;
                da.Update(aa);
                uow.Commit();
            }
        }
        public Announcement RemoveFromAnnouncement(int announcementAppId, AnnouncementTypeEnum type)
        {
            try
            {
                using (var uow = Update())
                {
                    var da  = new AnnouncementApplicationDataAccess(uow);
                    var aa  = da.GetById(announcementAppId);
                    var res = ServiceLocator.GetAnnouncementService(type).GetAnnouncementById(aa.AnnouncementRef);
                    if (!res.IsOwner && Context.Role != CoreRoles.DISTRICT_ADMIN_ROLE)
                    {
                        throw new ChalkableSecurityException(ChlkResources.ERR_SECURITY_EXCEPTION);
                    }

                    da.Delete(announcementAppId);
                    uow.Commit();
                    return(res);
                }
            }
            catch
            {
                throw new ChalkableException(string.Format(ChlkResources.ERR_CANT_DELETE_ANNOUNCEMENT_APPLICATION, announcementAppId));
            }
        }