protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateAsset createRule: return(CreateReturnAsync(createRule, async c => { GuardAsset.CanCreate(c); c.Tags = await tagService.NormalizeTagsAsync(c.AppId.Id, TagGroups.Assets, c.Tags, Snapshot.Tags); Create(c); return new AssetSavedResult(Version, Snapshot.FileVersion); })); case UpdateAsset updateRule: return(UpdateAsync(updateRule, c => { GuardAsset.CanUpdate(c); Update(c); return new AssetSavedResult(Version, Snapshot.FileVersion); })); case TagAsset tagAsset: return(UpdateAsync(tagAsset, async c => { GuardAsset.CanTag(c); c.Tags = await tagService.NormalizeTagsAsync(Snapshot.AppId.Id, TagGroups.Assets, c.Tags, Snapshot.Tags); Tag(c); })); case DeleteAsset deleteAsset: return(UpdateAsync(deleteAsset, async c => { GuardAsset.CanDelete(c); await tagService.NormalizeTagsAsync(Snapshot.AppId.Id, TagGroups.Assets, null, Snapshot.Tags); Delete(c); })); case RenameAsset renameAsset: return(UpdateAsync(renameAsset, c => { GuardAsset.CanRename(c, Snapshot.FileName); Rename(c); })); default: throw new NotSupportedException(); } }
protected Task On(RenameAsset command, CommandContext context) { return(handler.UpdateSyncedAsync <AssetDomainObject>(context, a => { GuardAsset.CanRename(command, a.Snapshot.FileName); a.Rename(command); })); }
public override Task <object> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateAsset createRule: return(CreateReturnAsync(createRule, c => { GuardAsset.CanCreate(c); Create(c); return new AssetSavedResult(NewVersion, Snapshot.FileVersion); })); case UpdateAsset updateRule: return(UpdateReturnAsync(updateRule, c => { GuardAsset.CanUpdate(c); Update(c); return new AssetSavedResult(NewVersion, Snapshot.FileVersion); })); case RenameAsset renameAsset: return(UpdateAsync(renameAsset, c => { GuardAsset.CanRename(c, Snapshot.FileName); Rename(c); })); case DeleteAsset deleteAsset: return(UpdateAsync(deleteAsset, c => { GuardAsset.CanDelete(c); Delete(c); })); default: throw new NotSupportedException(); } }