This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CQRS refactor
- Loading branch information
Showing
32 changed files
with
364 additions
and
227 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
namespace ToffApi.Command.CommandBuses; | ||
|
||
public abstract class Command | ||
{ | ||
protected Command(IHttpContextAccessor callerContext) | ||
{ | ||
CallerContext = callerContext; | ||
} | ||
|
||
public IHttpContextAccessor CallerContext; | ||
} | ||
{} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ToffApi.Command.CommandBuses; | ||
|
||
public class UpdatePfpCommand : Command | ||
{ | ||
public Guid UserId { get; set; } | ||
public IFormFile File { 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using ToffApi.Command.CommandBuses; | ||
using ToffApi.Command.CommandResults; | ||
using ToffApi.Services.CloudFlareR2Service; | ||
using ToffApi.Services.DataAccess; | ||
|
||
namespace ToffApi.Command.CommandHandlers; | ||
|
||
public class UserCommandHandler : CommandHandler | ||
{ | ||
private readonly IUserDataAccess _userDataAccess; | ||
private readonly IR2Service _r2Service; | ||
|
||
public UserCommandHandler(IUserDataAccess userDataAccess, IR2Service r2Service) | ||
{ | ||
_userDataAccess = userDataAccess; | ||
_r2Service = r2Service; | ||
} | ||
|
||
public async Task<UpdatePfpCommandResult> HandleAsync(UpdatePfpCommand command) | ||
{ | ||
var pfpUrl = await _r2Service.UploadObject(command.File); | ||
var url = await _userDataAccess.UpdateUserPfp(command.UserId, pfpUrl); | ||
var commandResult = new UpdatePfpCommandResult() { Url = url }; | ||
return commandResult; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ToffApi.Command.CommandResults; | ||
|
||
public class UpdatePfpCommandResult | ||
{ | ||
public string Url { 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
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
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
Oops, something went wrong.