Пример #1
0
        public IEnumerable <SubjectInfoData> GetAttachedSubjects(object refId, object subitemId, int pageIndex, int pageSize, object locationId = null, object languageId = null)
        {
            ArgumentValidator.IsNotNull("refId", refId);
            ArgumentValidator.IsNotNull("subitemId", subitemId);

            ReferenceInfoData reference = null;

            // Retrieve reference by refId
            RepositoryExceptionWrapper.Wrap(GetType(), () =>
            {
                ICriteria query = CurrentSession.CreateCriteria <ReferenceInfoData>();
                query.AddExpressionEq <ReferenceInfoData, object>(o => o.Id, refId);
                reference = query.UniqueResult <ReferenceInfoData>();
            });

            // Get attached content
            IEnumerable <SubjectInfoData> result = null;

            if (reference != null)
            {
                SubitemValueInfoData value = reference.Values.SingleOrDefault(o => object.Equals(o.SubitemId, subitemId));
                if (value != null && value.ValueInt.HasValue)
                {
                    object folderId   = value.ValueInt.Value;
                    int?   templateId = value.ValueText.TryToParse <int>();
                    result = GetSubjectsByFolder(folderId, templateId, pageIndex, pageSize, languageId);
                }
            }
            return(result);
        }
Пример #2
0
        public ReferenceInfoData GetReference(string urlAlias, object locationId, object languageId)
        {
            ArgumentValidator.IsNotNull("urlAlias", urlAlias);
            ReferenceInfoData result = null;

            RepositoryExceptionWrapper.Wrap(GetType(), () =>
            {
                ICriteria query = CurrentSession.CreateCriteria <ReferenceInfoData>();
                query.AddExpressionInsensitiveLike <ReferenceInfoData, string>(o => o.UrlAlias, urlAlias);
                result = query.UniqueResult <ReferenceInfoData>();
                AttachAdditionalContent(result, locationId, languageId);
            });

            return(result);
        }
Пример #3
0
        public ReferenceInfoData GetReference(object id)
        {
            ArgumentValidator.IsNotNull("id", id);
            ReferenceInfoData result = null;

            RepositoryExceptionWrapper.Wrap(GetType(), () =>
            {
                ICriteria query = CurrentSession.CreateCriteria <ReferenceInfoData>();
                query.AddExpressionEq <ReferenceInfoData, object>(o => o.Id, id);
                result = query.UniqueResult <ReferenceInfoData>();
                AttachAdditionalContent(result);
            });

            return(result);
        }
Пример #4
0
 private void AttachAdditionalContent(ReferenceInfoData reference, object locationId = null, object languageId = null)
 {
     // Get related content for current reference
     if (reference.Template.EnableCategory)
     {
         object templateId = reference.Template.Id;
         int    pageSize   = reference.Template.RelatedContentNo == 0 ? 6 : reference.Template.RelatedContentNo;
         object categoryId = null;
         ReferenceCategoryInfoData firstCategory = null;
         if (reference.ReferenceCategorys.Any())
         {
             firstCategory = reference.ReferenceCategorys.First();
         }
         if (firstCategory != null)
         {
             categoryId = firstCategory.Category.Id;
             reference.RelatedSubjects = GetSubjectsByCategory(categoryId, templateId, 1, pageSize);
         }
         else
         {
             reference.RelatedSubjects = GetSubjectsByTemplate(templateId, null, 1, pageSize);
         }
     }
     foreach (ZoneInfoData zone in reference.Template.Zones)
     {
         if (zone.Block != null)
         {
             foreach (SubitemInfoData item in zone.Block.Subitems)
             {
                 if (item.DucType == DucTypes.ReferenceCollection)
                 {
                     // get collectionId
                     SubitemValueInfoData value = reference.Values.SingleOrDefault(o => object.Equals(o.SubitemId, item.Id));
                     if (value != null && value.ValueInt.HasValue)
                     {
                         IQuery query1 = CurrentSession.GetNamedQuery("GetReferencesByCollection");
                         query1.SetParameter("collectionId", value.ValueInt.Value);
                         // set locationId
                         if (locationId != null)
                         {
                             query1.SetParameter("locationId", locationId);
                         }
                         else
                         {
                             query1.SetString("locationId", null);
                         }
                         // set languageId
                         if (languageId != null)
                         {
                             query1.SetParameter("languageId", languageId);
                         }
                         else
                         {
                             query1.SetString("languageId", null);
                         }
                         value.AttachedSubjects = query1.List <SubjectInfoData>();
                     }
                 }
                 else if (item.DucType == DucTypes.CommentList)
                 {
                     // get comment list
                 }
             }
         }
     }
 }
Пример #5
0
        public IServiceQueryResult <ReferenceInfoData> GetReference(string urlAlias, object locationId, object languageId)
        {
            ReferenceInfoData result = Repository.GetReference(urlAlias, locationId, languageId);

            return(ServiceResultFactory.BuildServiceQueryResult(result));
        }
Пример #6
0
        public IServiceQueryResult <ReferenceInfoData> GetReference(string urlAlias)
        {
            ReferenceInfoData result = Repository.GetReference(urlAlias);

            return(ServiceResultFactory.BuildServiceQueryResult(result));
        }
Пример #7
0
        public IServiceQueryResult <ReferenceInfoData> GetReference(object id)
        {
            ReferenceInfoData result = Repository.GetReference(id);

            return(ServiceResultFactory.BuildServiceQueryResult(result));
        }