Created
January 21, 2020 13:25
-
-
Save jasonmitchell/e3544718d75e6b92ec78e0704dd53c92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreateFolder | |
{ | |
public string Name { get; set; } | |
} | |
public class DeleteFolder | |
{ | |
public Guid Id { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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