Esempio n. 1
0
        public async void UpdateTags(string tags, string listName)
        {
            string[] tagList = tags.Split(',');
            foreach (string tag in tagList)
            {
                string trimmedTag = tag.Trim();
                if (!String.IsNullOrWhiteSpace(trimmedTag))
                {
                    string     logicalKey = listName + "-" + trimmedTag;
                    ArticleTag articleTag = await tagRepository.GetDocumentByKey(logicalKey);

                    if (null == articleTag)
                    {
                        articleTag            = new ArticleTag();
                        articleTag.LogicalKey = logicalKey;
                        articleTag.TagCount   = 1;
                        articleTag.Tag        = trimmedTag;
                    }
                    else
                    {
                        articleTag.TagCount += 1;
                    }
                    articleTag.ListName   = listName;
                    articleTag.TimeToLive = 3600 * 24 * 320; // Tags not used longer than one year can be deleted
                    await tagRepository.UpsertDocument(articleTag);
                }
            }
        }
Esempio n. 2
0
        private async Task PrepareArticle(string callingPage, string listName, string logicalKey, string documentId)
        {
            CallingPage = callingPage;
            ListName    = listName;
            if (!String.IsNullOrEmpty(logicalKey))
            {
                NewArticle.LogicalKey = logicalKey;
                Article existentDocument = await repository.GetDocumentByKey(logicalKey);

                if (null != existentDocument)
                {
                    NewArticle = existentDocument;
                }
            }
            else if (!String.IsNullOrEmpty(documentId))
            {
                NewArticle = await repository.GetDocument(documentId);
            }
            NewArticle.ListName = listName;
        }
Esempio n. 3
0
        public async Task <IActionResult> OnGetAsync(string permalink = null, string language = null, string message = null)
        {
            Categories = await _categoryRepository.GetDocuments(d => d.ListName == CategoryListName);

            CategoriesDisplay = Categories.ToDictionary(t => t.Category, t => t.CategoryDisplay ?? t.Category);
            Message           = message;
            IEnumerable <CalendarItem> documents;

            OverviewArticle = await _articleRepository.GetDocumentByKey(ArticleKey);

            DateTime compareDate = DateTime.Today.AddDays(-8);

            if (String.IsNullOrEmpty(permalink))
            {
                if (User.Identity.IsAuthenticated)
                {
                    documents = await _calendarRepository.GetDocuments();
                }
                else
                {
                    documents = await _calendarRepository.GetDocuments(d => d.EndDate > compareDate && d.PublicListing == true);
                }
                CalendarItems = documents.OrderBy(d => d.StartDate);
                await this.LogGetActivity();
            }
            else
            {
                string permaLinkLower = permalink.ToLower();
                ReferencedCalenderItem = (await _calendarRepository.GetDocuments(d => d.UrlTitle == permaLinkLower)).OrderByDescending(d => d.StartDate).FirstOrDefault();
                await this.LogActivity(permaLinkLower);

                if (ReferencedCalenderItem == null)
                {
                    // Now check if a category matches the given argument
                    documents = await _calendarRepository.GetDocuments(d => d.EndDate > compareDate && d.CalendarName.ToLower() == permaLinkLower && d.PublicListing == true);

                    if (null == documents)
                    {
                        return(new NotFoundResult());
                    }
                    CalendarItems = documents.OrderBy(d => d.StartDate);
                    return(Page());
                }
                ReferencedCalenderItem.Language = "de";
                if (!ReferencedCalenderItem.EnableTranslations)
                {
                    language = String.Empty;
                }
                if (!String.IsNullOrEmpty(language))
                {
                    ReferencedCalenderItem.Language = language;
                    if (language != "de")
                    {
                        ReferencedCalenderItem.Title = await _functionSiteTools.Translate(language, ReferencedCalenderItem.Title);

                        ReferencedCalenderItem.Summary = await _functionSiteTools.Translate(language, ReferencedCalenderItem.Summary);

                        ReferencedCalenderItem.Description = await _functionSiteTools.Translate(language, ReferencedCalenderItem.Description);
                    }
                }
                if (!ReferencedCalenderItem.PublicListing)
                {
                    ViewData["NoRobots"] = true;
                }
                if (ReferencedCalenderItem.Infos != null)
                {
                    List <ContentItem> infos = new List <ContentItem>(ReferencedCalenderItem.Infos);
                    this.HeaderItem = infos.Find(c => c.SortOrder == 0);
                    infos.ForEach(c => c.ReferenceId = ReferencedCalenderItem.Id);
                    if (ReferencedCalenderItem.Language != "de")
                    {
                        foreach (ContentItem c in infos)
                        {
                            c.Title = await _functionSiteTools.Translate(ReferencedCalenderItem.Language, c.Title);

                            c.Description = await _functionSiteTools.Translate(ReferencedCalenderItem.Language, c.Description);
                        }
                    }
                }
            }
            return(Page());
        }
Esempio n. 4
0
        public async Task <IActionResult> OnGetAsync(string category = null, string permalink = null, string language = null)
        {
            IEnumerable <TrackItem> documents;

            if (String.IsNullOrEmpty(category))
            {
                documents = await repository.GetDocuments(d => d.ListName == ListName);

                ArticleKey      = "wanderungen";
                OverviewArticle = await articleRepository.GetDocumentByKey(ArticleKey);

                Tracks = documents.OrderByDescending(d => d.Date);
                this.ViewData["Title"]       = ListName;
                this.ViewData["Description"] = "Wandern in der Eifel, im Bergischen Land, Siebengebirge, am Rhein und auf Reisen";
                await this.LogGetActivity();
            }
            else if (String.IsNullOrEmpty(permalink))
            {
                string categoryLower = category.ToLower();
                documents = await repository.GetDocuments(d => d.ListName == ListName && d.Category.ToLower() == categoryLower);

                ArticleKey      = "wanderungen-" + categoryLower;
                OverviewArticle = await articleRepository.GetDocumentByKey(ArticleKey);

                if (null == OverviewArticle)
                {
                    OverviewArticle = await articleRepository.GetDocumentByKey("wanderungen");
                }
                Tracks = documents.OrderByDescending(d => d.Date);
                this.ViewData["Title"]       = $"{ListName} - {category}";
                this.ViewData["Description"] = $"Wanderungen - {category}";
                await this.LogActivity(categoryLower);
            }
            else
            {
                string categoryLower  = category.ToLower();
                string permaLinkLower = permalink.ToLower();
                ReferencedTrack = (await repository.GetDocuments(d => d.ListName == ListName && d.Category.ToLower() == categoryLower && d.UrlTitle == permaLinkLower)).OrderByDescending(d => d.Date).FirstOrDefault();
                if (ReferencedTrack == null)
                {
                    return(new NotFoundResult());
                }
                ReferencedTrack.Language = "de";
                if (!String.IsNullOrEmpty(language))
                {
                    ReferencedTrack.Language    = language;
                    ReferencedTrack.Description = await _functionSiteTools.Translate(language, ReferencedTrack.Description);
                }
                this.ViewData["Title"]       = ReferencedTrack.Title;
                this.ViewData["Description"] = "Die Beschreibung zur Wanderung.";
                await this.LogActivity($"{categoryLower}/{permaLinkLower}");
            }
            Categories = await categoryRepository.GetDocuments(d => d.ListName == CategoryListName);

            CategoriesDisplay = Categories.ToDictionary(t => t.Category, t => t.CategoryDisplay ?? t.Category);
            if (null != Tracks)
            {
                foreach (TrackItem track in Tracks)
                {
                    if (CategoriesDisplay.ContainsKey(track.Category))
                    {
                        track.CategoryDisplay = CategoriesDisplay[track.Category];
                    }
                    else
                    {
                        track.CategoryDisplay = track.Category;
                    }
                }
            }
            return(Page());
        }
Esempio n. 5
0
        public async Task <IActionResult> OnGetAsync(string category = null, string permalink = null, string language = null)
        {
            IEnumerable <TrackItem> documents;

            if (String.IsNullOrEmpty(category))
            {
                return(RedirectToPage("./Ausfahrten"));
            }
            else if (String.IsNullOrEmpty(permalink))
            {
                string tourSetLower = category.ToLower();
                TourSet   = category;
                documents = await repository.GetDocuments(d => d.TourSet.ToLower() == tourSetLower);

                if (documents.Count() == 0)
                {
                    return(new NotFoundResult());
                }
                ArticleKey      = "tourset-" + tourSetLower;
                OverviewArticle = await articleRepository.GetDocumentByKey(ArticleKey);

                Tracks = documents.OrderBy(d => d.Date);
                if (null != OverviewArticle)
                {
                    this.ViewData["Title"] = OverviewArticle.Title;
                    if (!String.IsNullOrEmpty(OverviewArticle.PlainSummary))
                    {
                        this.ViewData["Description"] = OverviewArticle.PlainSummary;
                    }
                }
                await this.LogActivity(tourSetLower);
            }
            else
            {
                string categoryLower  = category.ToLower();
                string permaLinkLower = permalink.ToLower();
                ReferencedTrack = (await repository.GetDocuments(d => d.UrlTitle == permaLinkLower)).OrderByDescending(d => d.Date).FirstOrDefault();
                if (ReferencedTrack == null)
                {
                    return(new NotFoundResult());
                }
                ReferencedTrack.Language = "de";
                if (!String.IsNullOrEmpty(language))
                {
                    ReferencedTrack.Language    = language;
                    ReferencedTrack.Description = await _functionSiteTools.Translate(language, ReferencedTrack.Description);
                }
                this.ViewData["Title"] = ReferencedTrack.Title;
                if (!String.IsNullOrEmpty(ReferencedTrack.PlainDescription))
                {
                    this.ViewData["Description"] = ReferencedTrack.PlainDescription;
                }
                await this.LogActivity($"{categoryLower}/{permaLinkLower}");
            }

            Categories = await categoryRepository.GetDocuments(d => d.ListName == CategoryListName);

            CategoriesDisplay = Categories.ToDictionary(t => t.Category, t => t.CategoryDisplay ?? t.Category);
            if (null != Tracks)
            {
                foreach (TrackItem track in Tracks)
                {
                    if (CategoriesDisplay.ContainsKey(track.Category))
                    {
                        track.CategoryDisplay = CategoriesDisplay[track.Category];
                    }
                    else
                    {
                        track.CategoryDisplay = track.Category;
                    }
                }
            }
            return(Page());
        }