Skip to content

Instantly share code, notes, and snippets.

@jasonmitchell
Created January 21, 2020 13:25
Show Gist options
  • Save jasonmitchell/e3544718d75e6b92ec78e0704dd53c92 to your computer and use it in GitHub Desktop.
Save jasonmitchell/e3544718d75e6b92ec78e0704dd53c92 to your computer and use it in GitHub Desktop.
public class CreateFolder
{
public string Name { get; set; }
}
public class DeleteFolder
{
public Guid Id { get; set; }
}
public class FolderCommandHandlers : IHandle<CreateFolder, Guid>, IHandle<DeleteFolder>
{
public Task<Guid> Handle(CreateFolder command)
{
// do stuff
return Guid.NewGuid();
}
public Task Handle(DeleteFolder command)
{
// Do stuff
}
}
public class FoldersController
{
private readonly IHandle<CreateFolder, Guid> _createFolder;
private readonly IHandle<DeleteFolder> _deleteFolder;
public FoldersController(IHandle<CreateFolder, Guid> createFolder, IHandle<DeleteFolder> deleteFolder)
{
_createFolder = createFolder;
_deleteFolder = deleteFolder;
}
}
public interface IHandle<TCommand>
{
Task Handle(TCommand command);
}
public interface IHandle<TCommand, TResponse>
{
Task<TResponse> Handle(TCommand command);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment