Skip to content
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

Use ISender instead of IMediator in controllers #663

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Crypter.API/Controllers/ConsentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ namespace Crypter.API.Controllers;
[Route("api/user/consent")]
public class ConsentController : CrypterControllerBase
{
private readonly IMediator _mediator;
private readonly ISender _sender;

public ConsentController(IMediator mediator)
public ConsentController(ISender sender)
{
_mediator = mediator;
_sender = sender;
}

[HttpPost("recovery-key-risk")]
Expand All @@ -52,7 +52,7 @@ public ConsentController(IMediator mediator)
public async Task<IActionResult> ConsentToRecoveryKeyRisksAsync()
{
SaveAcknowledgementOfRecoveryKeyRisksCommand request = new SaveAcknowledgementOfRecoveryKeyRisksCommand(UserId);
await _mediator.Send(request);
await _sender.Send(request);
return Ok();
}
}
8 changes: 4 additions & 4 deletions Crypter.API/Controllers/MetricsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ namespace Crypter.API.Controllers;
[Route("api/metrics")]
public class MetricsController : CrypterControllerBase
{
private readonly IMediator _mediator;
private readonly ISender _sender;

public MetricsController(IMediator mediator)
public MetricsController(ISender sender)
{
_mediator = mediator;
_sender = sender;
}

[HttpGet("storage/public")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(PublicStorageMetricsResponse))]
public async Task<IActionResult> GetPublicStorageMetricsAsync(CancellationToken cancellationToken)
{
GetDiskMetricsQuery request = new GetDiskMetricsQuery();
GetDiskMetricsResult result = await _mediator.Send(request, cancellationToken);
GetDiskMetricsResult result = await _sender.Send(request, cancellationToken);
PublicStorageMetricsResponse response = new PublicStorageMetricsResponse(result.AllocatedBytes, result.FreeBytes);
return Ok(response);
}
Expand Down
12 changes: 6 additions & 6 deletions Crypter.API/Controllers/UserContactController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ namespace Crypter.API.Controllers;
[Route("api/user/contact")]
public class UserContactController : CrypterControllerBase
{
private readonly IMediator _mediator;
private readonly ISender _sender;

public UserContactController(IMediator mediator)
public UserContactController(ISender sender)
{
_mediator = mediator;
_sender = sender;
}

/// <summary>
Expand All @@ -65,7 +65,7 @@ public UserContactController(IMediator mediator)
public async Task<IActionResult> GetUserContactsAsync(CancellationToken cancellationToken)
{
GetUserContactsQuery request = new GetUserContactsQuery(UserId);
List<UserContact> result = await _mediator.Send(request, cancellationToken);
List<UserContact> result = await _sender.Send(request, cancellationToken);
return Ok(result);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ IActionResult MakeErrorResponse(AddUserContactError error)
}

AddUserContactCommand request = new AddUserContactCommand(UserId, username);
return await _mediator.Send(request)
return await _sender.Send(request)
.MatchAsync(
MakeErrorResponse,
Ok,
Expand All @@ -115,7 +115,7 @@ IActionResult MakeErrorResponse(AddUserContactError error)
public async Task<IActionResult> RemoveUserContactAsync([FromQuery] string username)
{
RemoveUserContactCommand request = new RemoveUserContactCommand(UserId, username);
await _mediator.Send(request);
await _sender.Send(request);
return Ok();
}
}
16 changes: 8 additions & 8 deletions Crypter.API/Controllers/UserKeyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ namespace Crypter.API.Controllers;
[Route("api/user/key")]
public class UserKeyController : CrypterControllerBase
{
private readonly IMediator _mediator;
private readonly ISender _sender;

public UserKeyController(IMediator mediator)
public UserKeyController(ISender sender)
{
_mediator = mediator;
_sender = sender;
}

[HttpGet("master")]
Expand All @@ -69,7 +69,7 @@ IActionResult MakeErrorResponse(GetMasterKeyError error)
}

GetMasterKeyQuery request = new GetMasterKeyQuery(UserId);
return await _mediator.Send(request, cancellationToken)
return await _sender.Send(request, cancellationToken)
.MatchAsync(
MakeErrorResponse,
Ok,
Expand Down Expand Up @@ -99,7 +99,7 @@ IActionResult MakeErrorResponse(InsertMasterKeyError error)
}

UpsertMasterKeyCommand request = new UpsertMasterKeyCommand(UserId, body, false);
return await _mediator.Send(request)
return await _sender.Send(request)
.MatchAsync(
MakeErrorResponse,
_ => Ok(),
Expand Down Expand Up @@ -131,7 +131,7 @@ IActionResult MakeErrorResponse(GetMasterKeyRecoveryProofError error)
}

GetMasterKeyProofQuery request = new GetMasterKeyProofQuery(UserId, body);
return await _mediator.Send(request, cancellationToken)
return await _sender.Send(request, cancellationToken)
.MatchAsync(
MakeErrorResponse,
Ok,
Expand All @@ -158,7 +158,7 @@ IActionResult MakeErrorResponse(GetPrivateKeyError error)
}

GetPrivateKeyQuery request = new GetPrivateKeyQuery(UserId);
return await _mediator.Send(request, cancellationToken)
return await _sender.Send(request, cancellationToken)
.MatchAsync(
MakeErrorResponse,
Ok,
Expand All @@ -185,7 +185,7 @@ IActionResult MakeErrorResponse(InsertKeyPairError error)
}

InsertKeyPairCommand request = new InsertKeyPairCommand(UserId, body);
return await _mediator.Send(request)
return await _sender.Send(request)
.MatchAsync(
MakeErrorResponse,
_ => Ok(),
Expand Down
Loading