예제 #1
0
        private static void UpdateDynamicImage(DynamicImage dymamicImage, Field newItem)
        {
            if (dymamicImage != null)
            {
                var dymamicImageDal = MapperFacade.DynamicImageMapper.GetDalObject(dymamicImage);
                if (dymamicImage.IsNew)
                {
                    dymamicImage.Id = newItem.Id;
                    dymamicImageDal = DefaultRepository.SimpleSave(dymamicImageDal);
                }
                else
                {
                    dymamicImageDal = DefaultRepository.SimpleUpdate(dymamicImageDal);
                }

                newItem.DynamicImage = MapperFacade.DynamicImageMapper.GetBizObject(dymamicImageDal);
            }
            else
            {
                var context = QPContext.EFContext;
                var dynamicImageFieldDAL = DefaultRepository.GetById <DynamicImageFieldDAL>(newItem.Id, context);
                if (dynamicImageFieldDAL != null)
                {
                    DefaultRepository.SimpleDelete(dynamicImageFieldDAL, context);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Возвращает версию статьи
        /// </summary>
        /// <param name="id">ID версии</param>
        /// <param name="articleId">ID статьи (параметр необязательный, необходимо передавать только, если версия - текущая</param>
        /// <returns>информация о версии статьи</returns>
        internal static ArticleVersion GetById(int id, int articleId = 0)
        {
            ArticleVersion articleVersion;

            if (id == ArticleVersion.CurrentVersionId)
            {
                if (articleId == 0)
                {
                    throw new Exception("Article id is not specified!");
                }

                var article = ArticleRepository.GetById(articleId);
                articleVersion = new ArticleVersion {
                    ArticleId = articleId, Id = id, Modified = article.Modified, LastModifiedBy = article.LastModifiedBy, LastModifiedByUser = article.LastModifiedByUser, Article = article
                };
            }
            else
            {
                var articleVersionDal = DefaultRepository.GetById <ArticleVersionDAL>(id);
                if (articleVersionDal == null)
                {
                    return(null);
                }

                articleVersionDal.LastModifiedByUserReference.Load();

                articleVersion = MapperFacade.ArticleVersionMapper.GetBizObject(articleVersionDal);
                if (articleVersion != null)
                {
                    articleVersion.Article = ArticleRepository.GetById(articleVersion.ArticleId);
                }
            }

            return(articleVersion);
        }
예제 #3
0
 internal static ContentGroup GetGroupById(int id) => MapperFacade.ContentGroupMapper.GetBizObject(DefaultRepository.GetById <ContentGroupDAL>(id));
예제 #4
0
        internal static DynamicImage GetDynamicImageInfoById(int fieldId)
        {
            var info = DefaultRepository.GetById <DynamicImageFieldDAL>(fieldId);

            return(info == null ? null : MapperFacade.DynamicImageMapper.GetBizObject(info));
        }