-
Notifications
You must be signed in to change notification settings - Fork 0
V3.10 create cqrs vertical slice minimal api #115
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
59 commits
Select commit
Hold shift + click to select a range
09cc4a0
Add better documentation to Accounts Api Endpoints
lakatoshv bf51d0c
Add better documentation to Comments Api Endpoints
lakatoshv d22a5e9
Add Health check Api Endpoints
lakatoshv 9b505fc
Add better documentation to Messages Api Endpoints
lakatoshv 9af35e6
Add better documentation to Posts Api Endpoints
lakatoshv 2fdb91d
Created Blog vertical slice CQRS Minimal Api project
lakatoshv 290e6e6
Add Cache setups
lakatoshv cc503d8
Add Swagger configuration
lakatoshv 52ac242
Add validation filter
lakatoshv c006ff2
Add Swagger extentions
lakatoshv dd22890
Add view models
lakatoshv a1d4761
Add health check configuration
lakatoshv 0c0f94c
Add mappers
lakatoshv a20a796
Add Api versioning installer
lakatoshv d9e854f
Add services Installer extentions
lakatoshv 003d94a
Add base services installers
lakatoshv 752728d
Add services installer
lakatoshv 0dc68ec
Add authentication and authorization services installer
lakatoshv 11ff8b4
Add CORS installer
lakatoshv c671c4d
Add Data repositories installers
lakatoshv 846a3a2
Add Database installer
lakatoshv 6a67180
Add Email Installer
lakatoshv 9e4c5f6
Configure autentication and authorization
lakatoshv 4f65255
Configure validations
lakatoshv f969c42
Add base configurations
lakatoshv 87c4142
Configure routes
lakatoshv e822033
Configure base command and command handler interfaces
lakatoshv 9e15553
Configure base query and query handler interfaces
lakatoshv 488173b
Add get all users query and query handler in accounts feature
lakatoshv 7e01c7a
Add initialize query and query handler in accounts feature
lakatoshv ba198a2
Add send confirmation email query and query handler in accounts feature
lakatoshv 57f51e5
Add users activity query and query handler in accounts feature
lakatoshv c2ba491
Add login command and command handler in accounts feature
lakatoshv ea2a12c
Add login endpoint in accounts feature
lakatoshv 490a7e2
Add register command and command handler in accounts feature
lakatoshv ef530da
Add register endpoint in accounts feature
lakatoshv 456c72c
Add comments activity query and query handler in accounts feature
lakatoshv c6237a8
Add create comment command and command handler in comments feature
lakatoshv c08837c
Add create comment endpoint in comments feature
lakatoshv 18494f0
Add get all query and query handler in comments feature
lakatoshv 579a841
Add get comment by id query and query handler in comments feature
lakatoshv ca5595d
Add get comments by filter query and query handler in comments feature
lakatoshv ade15ec
Add get comments by post query and query handler in comments feature
lakatoshv 819b5c5
Add initialize query and query handler in health check feature
lakatoshv 4469e2a
Add create message command and command handler in messages feature
lakatoshv 243d392
Add create message endpoint in messages feature
lakatoshv 189290f
Add get all query and query handler in messages feature
lakatoshv 996966d
Add get by id query and query handler in messages feature
lakatoshv cf4240c
Add get recipient messages query and query handler in messages feature
lakatoshv 06827d3
Add get sender messages query and query handler in messages feature
lakatoshv 0833732
Add create post command and command handler in posts feature
lakatoshv 90d79bb
Add create post endpoint posts feature
lakatoshv b3b95dd
Add Carter, Mapster and MediatR configurations for endpoints
lakatoshv 2a9d4e9
Cofigure program
lakatoshv 3cfcab9
Add get all posts query and query handler in posts feature
lakatoshv fbe573f
Add get post by id query and query handler in posts feature
lakatoshv be0f086
Add get posts query and query handler in posts feature
lakatoshv d7871b8
Add posts activity query and query handler in posts feature
lakatoshv 977e837
Add users posts query and query handler in posts feature
lakatoshv 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
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
34 changes: 34 additions & 0 deletions
34
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/BlogVerticalSliceCQRSMinimalApi.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,34 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <NoWarn>$(NoWarn);1591</NoWarn> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Carter" Version="10.0.0" /> | ||
| <PackageReference Include="Mapster" Version="7.4.0" /> | ||
| <PackageReference Include="MediatR" Version="14.1.0" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.3" /> | ||
| <PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="10.0.3" /> | ||
| <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.3" /> | ||
| <PackageReference Include="Asp.Versioning.Http" Version="8.1.1" /> | ||
| <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" /> | ||
| <PackageReference Include="AspNetCore.HealthChecks.Redis" Version="9.0.0" /> | ||
| <PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.4" /> | ||
| <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="10.0.1" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Aspire\Blog.Aspire\Blog.Aspire.ServiceDefaults\Blog.Aspire.ServiceDefaults.csproj" /> | ||
| <ProjectReference Include="..\Services\Blog.Services\Blog.EntityServices.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
9 changes: 9 additions & 0 deletions
9
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/BlogVerticalSliceCQRSMinimalApi.csproj.user
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 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup> | ||
| <ActiveDebugProfile>http</ActiveDebugProfile> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
| <DebuggerFlavor>ProjectDebugger</DebuggerFlavor> | ||
| </PropertyGroup> | ||
| </Project> |
6 changes: 6 additions & 0 deletions
6
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/BlogVerticalSliceCQRSMinimalApi.http
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,6 @@ | ||
| @BlogVerticalSliceCQRSMinimalApi_HostAddress = http://localhost:5037 | ||
|
|
||
| GET {{BlogVerticalSliceCQRSMinimalApi_HostAddress}}/weatherforecast/ | ||
| Accept: application/json | ||
|
|
||
| ### |
16 changes: 16 additions & 0 deletions
16
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/ICommand.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,16 @@ | ||
| using MediatR; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| //will not return any response | ||
| public interface ICommand : ICommand<Unit>; | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| /// <typeparam name="TResponse"></typeparam> | ||
| //will return TResponse | ||
| public interface ICommand<out TResponse> : IRequest<TResponse>; |
14 changes: 14 additions & 0 deletions
14
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/ICommandHandler.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,14 @@ | ||
| using MediatR; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| //will not return any response | ||
| public interface ICommandHandler<in TCommand> | ||
| : IRequestHandler<TCommand, Unit> | ||
| where TCommand : ICommand<Unit>; | ||
|
|
||
| //will return TResponse | ||
| public interface ICommandHandler<in TCommand, TResponse> | ||
| : IRequestHandler<TCommand, TResponse> | ||
| where TCommand : ICommand<TResponse> | ||
| where TResponse : notnull; |
6 changes: 6 additions & 0 deletions
6
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/IQuery.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,6 @@ | ||
| using MediatR; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| public interface IQuery<out TResponse> : IRequest<TResponse> | ||
| where TResponse : notnull; |
9 changes: 9 additions & 0 deletions
9
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/IQueryHandler.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,9 @@ | ||
| using MediatR; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| //will return TResponse | ||
| public interface IQueryHandler<in TQuery, TResponse> | ||
| : IRequestHandler<TQuery, TResponse> | ||
| where TQuery : IQuery<TResponse> | ||
| where TResponse : notnull; |
4 changes: 4 additions & 0 deletions
4
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/SearchParametersQuery.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,4 @@ | ||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| public record SearchParametersQuery(string OrderBy, string SortBy, int? CurrentPage, int? PageSize, string DisplayType) | ||
| : SortParametersQuery(OrderBy, SortBy, CurrentPage, PageSize, DisplayType); |
3 changes: 3 additions & 0 deletions
3
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/CQRSExtensions/SortParametersQuery.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,3 @@ | ||
| namespace BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| public record SortParametersQuery(string OrderBy, string SortBy, int? CurrentPage, int? PageSize, string DisplayType); |
88 changes: 88 additions & 0 deletions
88
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/Cache/CachedAttribute.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,88 @@ | ||
| namespace BlogVerticalSliceCQRSMinimalApi.Cache; | ||
|
|
||
| using System; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.Mvc.Filters; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Blog.CommonServices.Interfaces; | ||
| using Blog.Core.Configuration; | ||
|
|
||
| /// <summary> | ||
| /// Cached attribute. | ||
| /// </summary> | ||
| /// <seealso cref="Attribute" /> | ||
| /// <seealso cref="IAsyncActionFilter" /> | ||
| /// <remarks> | ||
| /// Initializes a new instance of the <see cref="CachedAttribute"/> class. | ||
| /// </remarks> | ||
| /// <param name="lifeTimeSeconds">The lifetime seconds.</param> | ||
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | ||
| public class CachedAttribute(int lifeTimeSeconds) | ||
| : Attribute, IAsyncActionFilter | ||
| { | ||
| /// <summary> | ||
| /// The lifetime seconds. | ||
| /// </summary> | ||
| private readonly int _lifeTimeSeconds = lifeTimeSeconds; | ||
|
|
||
| /// <summary> | ||
| /// Called asynchronously before the action, after model binding is complete. | ||
| /// </summary> | ||
| /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext" />.</param> | ||
| /// <param name="next">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ActionExecutionDelegate" />. Invoked to execute the next action filter or the action itself.</param> | ||
| public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) | ||
| { | ||
| var cacheSettings = context.HttpContext.RequestServices.GetRequiredService<RedisCacheConfiguration>(); | ||
| if (!cacheSettings.Enabled) | ||
| { | ||
| await next(); | ||
| return; | ||
| } | ||
|
|
||
| var cachedService = context.HttpContext.RequestServices.GetRequiredService<IResponseCacheService>(); | ||
| var cachedKey = GenerateCacheKeyFromRequest(context.HttpContext.Request); | ||
|
|
||
| var cachedResponse = await cachedService.GetCachedResponseAsync(cachedKey); | ||
| if (!string.IsNullOrEmpty(cachedResponse)) | ||
| { | ||
| var contentResult = new ContentResult | ||
| { | ||
| Content = cachedResponse, | ||
| ContentType = "application/json", | ||
| StatusCode = 200, | ||
| }; | ||
|
|
||
| context.Result = contentResult; | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| var executedContext = await next(); | ||
| if (executedContext.Result is OkObjectResult okObjectResult) | ||
| { | ||
| await cachedService.CacheResponseAsync(cachedKey, okObjectResult.Value, TimeSpan.FromSeconds(_lifeTimeSeconds)); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generates the cache key from request. | ||
| /// </summary> | ||
| /// <param name="request">The request.</param> | ||
| /// <returns></returns> | ||
| private static string GenerateCacheKeyFromRequest(HttpRequest request) | ||
| { | ||
| var keyBuilder = new StringBuilder(); | ||
| keyBuilder.Append($"{request.Path}"); | ||
|
|
||
| foreach (var (key, value) in request.Query.OrderBy(x => x.Key)) | ||
| { | ||
| keyBuilder.Append($"{key}-{value}"); | ||
| } | ||
|
|
||
| return keyBuilder.ToString(); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/Features/Accounts/GetAllUsers/GetAllUsersQuery.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,6 @@ | ||
| using Blog.Contracts.V1.Responses.UsersResponses; | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.GetAllUsers; | ||
|
|
||
| public record GetAllUsersQuery : IQuery<List<AccountResponse>>; |
23 changes: 23 additions & 0 deletions
23
.../BlogVerticalSliceCQRSMinimalApi/Features/Accounts/GetAllUsers/GetAllUsersQueryHandler.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,23 @@ | ||
| using AutoMapper; | ||
| using Blog.Contracts.V1.Responses.UsersResponses; | ||
| using Blog.Data.Models; | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
| using Microsoft.AspNetCore.Identity; | ||
| using Microsoft.EntityFrameworkCore; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.GetAllUsers; | ||
|
|
||
| public class GetAllUsersQueryHandler( | ||
| UserManager<ApplicationUser> userManager, | ||
| IMapper mapper) | ||
| : IQueryHandler<GetAllUsersQuery, List<AccountResponse>> | ||
| { | ||
| public async Task<List<AccountResponse>> Handle(GetAllUsersQuery query, CancellationToken cancellationToken) | ||
| { | ||
| var users = await userManager.Users | ||
| .Include(u => u.Roles) | ||
| .ToListAsync(cancellationToken: cancellationToken); | ||
|
|
||
| return mapper.Map<List<AccountResponse>>(users); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/Features/Accounts/Initialize/InitializeQuery.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,6 @@ | ||
| using Blog.Contracts.V1.Responses.UsersResponses; | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.Initialize; | ||
|
|
||
| public record InitializeQuery(string UserId) : IQuery<List<RoleResponse>>; |
21 changes: 21 additions & 0 deletions
21
...pp/BlogVerticalSliceCQRSMinimalApi/Features/Accounts/Initialize/InitializeQueryHandler.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,21 @@ | ||
| using AutoMapper; | ||
| using Blog.Contracts.V1.Responses.UsersResponses; | ||
| using Blog.Data.Models; | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
| using Microsoft.AspNetCore.Identity; | ||
| using Microsoft.EntityFrameworkCore; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.Initialize; | ||
|
|
||
| public class InitializeQueryHandler( | ||
| RoleManager<ApplicationRole> roleManager, | ||
| IMapper mapper) | ||
| : IQueryHandler<InitializeQuery, List<RoleResponse>> | ||
| { | ||
| public async Task<List<RoleResponse>> Handle(InitializeQuery query, CancellationToken cancellationToken) | ||
| { | ||
| var roles = await roleManager.Roles.ToListAsync(cancellationToken: cancellationToken); | ||
|
|
||
| return mapper.Map<List<RoleResponse>>(roles); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/Features/Accounts/Login/LoginCommand.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,6 @@ | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.Login; | ||
|
|
||
| public record LoginCommand(string Email, string Password) | ||
| : ICommand<string>; |
11 changes: 11 additions & 0 deletions
11
BlogWebApp/BlogVerticalSliceCQRSMinimalApi/Features/Accounts/Login/LoginCommandHandler.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,11 @@ | ||
| using Blog.EntityServices.EntityFrameworkServices.Identity.Auth; | ||
| using BlogVerticalSliceCQRSMinimalApi.CQRSExtensions; | ||
|
|
||
| namespace BlogVerticalSliceCQRSMinimalApi.Features.Accounts.Login; | ||
|
|
||
| public class LoginCommandHandler(IAuthService authService) | ||
| : ICommandHandler<LoginCommand, string> | ||
| { | ||
| public async Task<string> Handle(LoginCommand command, CancellationToken cancellationToken) | ||
| => await authService.GetJwtAsync(command.Email, command.Password); | ||
| } |
Oops, something went wrong.
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.
test comment