public AnnouncementApplication AddToAnnouncement(int announcementId, AnnouncementTypeEnum type, Guid applicationId)
        {
            var app = ServiceLocator.ServiceLocatorMaster.ApplicationService.GetApplicationById(applicationId);

            EnsureApplicationPermission(app.Id);

            using (var uow = Update())
            {
                var ann = ServiceLocator.GetAnnouncementService(type).GetAnnouncementDetails(announcementId);
                if (!ApplicationSecurity.CanAddToAnnouncement(app, ann, Context))
                {
                    throw new ChalkableSecurityException();
                }
                var aa = new AnnouncementApplication
                {
                    AnnouncementRef = announcementId,
                    ApplicationRef  = applicationId,
                    Active          = false,
                    Order           = ServiceLocator.GetAnnouncementService(type).GetNewAnnouncementItemOrder(ann)
                };
                var da = new AnnouncementApplicationDataAccess(uow);
                da.Insert(aa);
                uow.Commit();
                aa = da.GetAll(new AndQueryCondition
                {
                    { nameof(AnnouncementApplication.AnnouncementRef), announcementId },
                    { nameof(AnnouncementApplication.ApplicationRef), applicationId },
                    { nameof(AnnouncementApplication.Active), false }
                }).OrderByDescending(x => x.Id).First();
                return(aa);
            }
        }
        public static IList <AnnouncementApplication> CopyAnnApplications(IList <AnnouncementApplication> annAppsForCopying, IList <int> toAnnouncementIds, UnitOfWork unitOfWork)
        {
            var da = new AnnouncementApplicationDataAccess(unitOfWork);

            foreach (var toAnnouncementId in toAnnouncementIds)
            {
                var res = annAppsForCopying.Select(aa => new AnnouncementApplication
                {
                    ApplicationRef  = aa.ApplicationRef,
                    Active          = aa.Active,
                    Order           = aa.Order,
                    AnnouncementRef = toAnnouncementId,
                }).ToList();
                da.Insert(res);
            }
            return(da.GetAnnouncementApplicationsbyAnnIds(toAnnouncementIds));
        }