private Page ToMetaWeblogPage(Pages.Page page) { var mPage = new Page { title = page.Title, description = page.RawHtmlContent, dateCreated = _dateTimeResolver.ToTimeZone(page.CreateTimeUtc), categories = Array.Empty <string>(), page_id = page.Id.ToString(), wp_author_id = _blogConfig.GeneralSettings.OwnerName }; return(mPage); }
public async Task <bool> EditPageAsync(string blogid, string pageid, string username, string password, Page page, bool publish) { EnsureUser(username, password); try { if (!Guid.TryParse(pageid, out var id)) { throw new ArgumentException("Invalid ID", nameof(pageid)); } var pageRequest = new UpdatePageRequest { Title = page.title, HideSidebar = true, MetaDescription = string.Empty, HtmlContent = page.description, CssContent = string.Empty, IsPublished = publish, Slug = ToSlug(page.title) }; await _pageService.UpdateAsync(id, pageRequest); return(true); } catch (Exception e) { _logger.LogError(e, e.Message); throw new MetaWeblogException(e.Message); } }
public Task <bool> EditPageAsync(string blogid, string pageid, string username, string password, WilderMinds.MetaWeblog.Page page, bool publish) { EnsureUser(username, password); return(TryExecuteAsync(async() => { if (!Guid.TryParse(pageid, out var id)) { throw new ArgumentException("Invalid ID", nameof(pageid)); } var pageRequest = new UpdatePageRequest { Title = page.title, HideSidebar = true, MetaDescription = string.Empty, HtmlContent = page.description, CssContent = string.Empty, IsPublished = publish, Slug = ToSlug(page.title) }; await _blogPageService.UpdateAsync(id, pageRequest); return true; })); }
public async Task <string> AddPageAsync(string blogid, string username, string password, Page page, bool publish) { EnsureUser(username, password); try { var pageRequest = new UpdatePageRequest { Title = page.title, HideSidebar = true, MetaDescription = string.Empty, HtmlContent = page.description, CssContent = string.Empty, IsPublished = publish, Slug = ToSlug(page.title) }; var uid = await _pageService.CreateAsync(pageRequest); return(uid.ToString()); } catch (Exception e) { _logger.LogError(e, e.Message); throw new MetaWeblogException(e.Message); } }
public Task <string> AddPageAsync(string blogid, string username, string password, WilderMinds.MetaWeblog.Page page, bool publish) { EnsureUser(username, password); return(TryExecuteAsync(async() => { var pageRequest = new UpdatePageRequest { Title = page.title, HideSidebar = true, MetaDescription = string.Empty, HtmlContent = page.description, CssContent = string.Empty, IsPublished = publish, Slug = ToSlug(page.title) }; var uid = await _blogPageService.CreateAsync(pageRequest); return uid.ToString(); })); }