public override async Task <bool> Update(Post value, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(value.Id)) { throw new Exception("No post id"); } PostMetadata metadata = new PostMetadata(value); string result = ObjectTextual.Format(metadata, value.Content.Raw); await File.WriteAllTextAsync(GetAbsolutePath(value.Id), result, System.Text.Encoding.UTF8, cancellationToken); return(true); }
public override async Task <string?> Create(Post value, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(value.Id)) { value.Id = Guid.NewGuid().ToString(); } PostMetadata metadata = new PostMetadata(value); string result = ObjectTextual.Format(metadata, value.Content.Raw); await File.WriteAllTextAsync(GetAbsolutePath(value.Id), result, System.Text.Encoding.UTF8, cancellationToken); return(value.Id); }