Users sometimes make mistakes. They should be able to undo a deletion. To allow this, create a new fact type that represents the restoration.
To restore a site, define a fact type that refers to the deletion of that site. It needs no additional parameters.
[FactType("Blog.Site.Restored")]
public record SiteRestored(SiteDeleted deleted) { }
Renderer.RenderTypes(typeof(SiteRestored))
Create an instance of this fact to indicate that the deletion should no longer take effect.
var siteRestored = await jinagaClient.Fact(new SiteRestored(siteDeleted));
jinagaClient.RenderFacts(siteRestored)
As you might imagine, the specification doesn't honor this new fact yet.
sites = await jinagaClient.Query(sitesByUser, user);
sites.Count()
0
But if we filter the deletions to include only those that don't have a successor restore fact, then we get the desired behavior.
sitesByUser = Given<User>.Match((user, facts) =>
from site in facts.OfType<Site>()
where site.creator == user
where !facts.Any<SiteDeleted>(
sd => sd.site == site &&
// Honor only the site deletion that have not been restored
!facts.Any<SiteRestored>(sr => sr.deleted == sd))
select site);
sites = await jinagaClient.Query(sitesByUser, user);
sites.Count()
1