-
Notifications
You must be signed in to change notification settings - Fork 0
new project Applications.Abstractions for results #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d200b42
new project Applications.Abstractions for results
imhmdi 4b743d9
update packages
imhmdi d444e44
update ef packages
imhmdi ae10d88
update packages
imhmdi 9f84c2c
Created `ResultOrientedCommandHandlerDecorator.cs` for structured com…
imhmdi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
TodoSample/Core/Application.Contracts/TodoItems/Commands/CreateTodoItemCommand.cs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,19 @@ | ||
| | ||
| using Honamic.Framework.Applications.Results; | ||
| using Honamic.Framework.Commands; | ||
|
|
||
| namespace Honamic.Todo.Application.TodoItems.Commands; | ||
| public record CreateTodoItemCommand(string title, string content, List<string> tags) : ICommand; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| public record CreateTodoItem2Command(string title, string content, List<string> tags) | ||
| : ICommand<Result<CreateTodoItem2ResultCommand>>; | ||
|
|
||
|
|
||
|
|
||
| public class CreateTodoItem2ResultCommand | ||
| { | ||
| public long Id { get; set; } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
33 changes: 33 additions & 0 deletions
33
TodoSample/Core/Application/TodoItems/CommandHandlers/CreateTodoItem2CommandHandler.cs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using Honamic.Framework.Applications.Results; | ||
| using Honamic.Framework.Commands; | ||
| using Honamic.Framework.Domain; | ||
| using Honamic.Todo.Application.TodoItems.Commands; | ||
| using Honamic.Todo.Domain.TodoItems; | ||
|
|
||
| namespace Honamic.Todo.Application.TodoItems.CommandHandlers; | ||
| internal class CreateTodoItem2CommandHandler : | ||
| ICommandHandler<CreateTodoItem2Command, Result<CreateTodoItem2ResultCommand>> | ||
| { | ||
| private readonly ITodoItemRepository _todoItemRepository; | ||
| private readonly IIdGenerator _idGenerator; | ||
|
|
||
| public CreateTodoItem2CommandHandler(ITodoItemRepository todoItemRepository, IIdGenerator idGenerator) | ||
| { | ||
| _todoItemRepository = todoItemRepository; | ||
| _idGenerator = idGenerator; | ||
| } | ||
|
|
||
| public async Task<Result<CreateTodoItem2ResultCommand>> HandleAsync(CreateTodoItem2Command command, CancellationToken cancellationToken) | ||
imhmdi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| var todoItem = new TodoItem(_idGenerator.GetNewId(), command.title, command.content, command.tags); | ||
| await _todoItemRepository.InsertAsync(todoItem); | ||
|
|
||
| var result = new CreateTodoItem2ResultCommand | ||
| { | ||
| Id = todoItem.Id | ||
| }; | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
30
TodoSample/Endpoints/WebApi/Honamic.Todo.Endpoints.WebApi/TodoItems/TodoItems2Controller.cs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using Honamic.Framework.Applications.Results; | ||
| using Honamic.Framework.Commands; | ||
| using Honamic.Todo.Application.TodoItems.Commands; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace Honamic.Todo.Endpoints.WebApi.Controllers; | ||
|
|
||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class TodoItems2Controller : ControllerBase | ||
| { | ||
| private readonly ILogger<TodoItemsController> _logger; | ||
| private readonly ICommandBus _commandBus; | ||
|
|
||
| public TodoItems2Controller(ILogger<TodoItemsController> logger, ICommandBus commandBus) | ||
| { | ||
| _logger = logger; | ||
| _commandBus = commandBus; | ||
| } | ||
|
|
||
| [HttpPost] | ||
| public async Task<Result<CreateTodoItem2ResultCommand>> Post([FromBody] CreateTodoItem2Command model, CancellationToken cancellationToken) | ||
| { | ||
| return await _commandBus | ||
| .DispatchAsync<CreateTodoItem2Command, Result<CreateTodoItem2ResultCommand>> | ||
| (model, cancellationToken); | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...ns/Exceptions/UnauthenticatedException.cs → ...ns/Exceptions/UnauthenticatedException.cs
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...tions/Exceptions/UnauthorizedException.cs → ...tions/Exceptions/UnauthorizedException.cs
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
src/Core/Applications.Abstractions/Honamic.Framework.Applications.Abstractions.csproj
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||||||||
|
|
||||||||||
| <PropertyGroup> | ||||||||||
| <TargetFramework>net8.0</TargetFramework> | ||||||||||
| <ImplicitUsings>enable</ImplicitUsings> | ||||||||||
| <Nullable>enable</Nullable> | ||||||||||
| <RootNamespace>$(MSBuildProjectName.Replace(" ", "_").Replace(".Abstractions", ""))</RootNamespace> | ||||||||||
|
||||||||||
| <RootNamespace>$(MSBuildProjectName.Replace(" ", "_").Replace(".Abstractions", ""))</RootNamespace> | |
| <!-- Define a property to generate the RootNamespace by replacing spaces with underscores and removing ".Abstractions" --> | |
| <GeneratedRootNamespace>$(MSBuildProjectName.Replace(" ", "_").Replace(".Abstractions", ""))</GeneratedRootNamespace> | |
| <RootNamespace>$(GeneratedRootNamespace)</RootNamespace> |
2 changes: 1 addition & 1 deletion
2
...e/Abstractions/Results/HttpStatusCodes.cs → ...s.Abstractions/Results/HttpStatusCodes.cs
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
src/Facade/Abstractions/Results/Result.cs → ...plications.Abstractions/Results/Result.cs
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...ade/Abstractions/Results/ResultMessage.cs → ...ons.Abstractions/Results/ResultMessage.cs
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...tions/Results/ResultMessagesExtensions.cs → ...tions/Results/ResultMessagesExtensions.cs
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...cade/Abstractions/Results/ResultStatus.cs → ...ions.Abstractions/Results/ResultStatus.cs
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
بهتره در یک فایل جدا نگهداری شود