示例#1
0
        private async void UpdatePageAfterChoosingTodaysPost(Page result, DateTimeOffset dateTimeOffset)
        {
            // TODO REHACER
            var newTitle = result.Title.ToTitleWithDate(dateTimeOffset);
            var fullPage = await _client.GetPageAsync(result.Path, true);

            await _secureClient.EditPageAsync(result.Path, newTitle, fullPage.Content.ToArray());
        }
示例#2
0
        public async Task <bool> StoreDateForPath(DateTimeOffset date, string path)
        {
            var page = await _client.GetPageAsync(path, returnContent : true);

            var pageNodeList = page.Content;
            var result       = _coreLogicService.ExtractInnerDataFromPage(page) ?? new TelegraphPostInnerDataDto();

            result.PostDate = date;
            var serializedResult = JsonSerializer.Serialize(result, new JsonSerializerOptions {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            });

            if (pageNodeList.Any(node => node.Tag == "code"))
            {
                pageNodeList.RemoveAll(x => x.Tag == "code");
            }

            var pageTitle = page.Title.ToTitleWithDate(date);

            if (pageTitle.Length >= 256)
            {
                pageTitle = pageTitle.Substring(0, 255);
            }

            pageNodeList.Add(new NodeElement("code", null, serializedResult));
            var editedPage = await _secureClient.EditPageAsync(
                page.Path,
                pageTitle,
                pageNodeList.ToArray(),
                page.AuthorName,
                page.AuthorUrl,
                true
                );

            return(editedPage.Content.Any(x => x.Tag == "code" && x.Children.Any(y => y.Attributes["value"] == serializedResult)));
        }