Example #1
0
        public GetPageTranslationsResponse Get(GetPageTranslationsRequest request)
        {
            var languageGroupIdentifier = GetPageLanguageGroupIdentifier(request);

            // Page has no translations
            if (!languageGroupIdentifier.HasValue)
            {
                return(new GetPageTranslationsResponse {
                    Data = new DataListResponse <PageTranslationModel>()
                });
            }

            request.Data.SetDefaultOrder("Title");

            // Load translations
            var query = repository
                        .AsQueryable <Module.Pages.Models.PageProperties>()
                        .Where(p => p.LanguageGroupIdentifier == languageGroupIdentifier.Value);

            var dataListResult = query.Select(p => new PageTranslationModel
            {
                Id           = p.Id,
                Title        = p.Title,
                PageUrl      = p.PageUrl,
                LanguageId   = p.Language != null ? p.Language.Id : (System.Guid?)null,
                LanguageCode = p.Language != null ? p.Language.Code : null,
                IsPublished  = p.Status == PageStatus.Published,
                PublishedOn  = p.PublishedOn
            }).ToDataListResponse(request);

            return(new GetPageTranslationsResponse {
                Data = dataListResult
            });
        }
Example #2
0
        private System.Guid?GetPageLanguageGroupIdentifier(GetPageTranslationsRequest request)
        {
            // Get page language group identifier
            var query = repository.AsQueryable <Module.Pages.Models.PageProperties>();

            if (request.PageId.HasValue)
            {
                query = query.Where(p => p.Id == request.PageId.Value);
            }
            else
            {
                var url = urlService.FixUrl(request.PageUrl);
                query = query.Where(p => p.PageUrl == url);
            }

            return(query.Select(p => p.LanguageGroupIdentifier).FirstOrDefault());
        }