-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c099a7
commit 8c187d1
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
.../src/Devices.Application/Identities/Queries/GetDeletionProcess/GetDeletionProcessQuery.cs
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,9 @@ | ||
using Backbone.Modules.Devices.Application.DTOs; | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Devices.Application.Identities.Queries.GetDeletionProcess; | ||
|
||
public class GetDeletionProcessQuery : IRequest<IdentityDeletionProcessDTO> | ||
{ | ||
public required string Id { get; set; } | ||
} |
29 changes: 29 additions & 0 deletions
29
Modules/Devices/src/Devices.Application/Identities/Queries/GetDeletionProcess/Handler.cs
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,29 @@ | ||
using Backbone.BuildingBlocks.Application.Abstractions.Exceptions; | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.UserContext; | ||
using Backbone.Modules.Devices.Application.DTOs; | ||
using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository; | ||
using Backbone.Modules.Devices.Domain.Entities.Identities; | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Devices.Application.Identities.Queries.GetDeletionProcess; | ||
|
||
public class Handler : IRequestHandler<GetDeletionProcessQuery, IdentityDeletionProcessDTO> | ||
{ | ||
private readonly IIdentitiesRepository _identitiesRepository; | ||
private readonly IUserContext _userContext; | ||
|
||
public Handler(IIdentitiesRepository identitiesRepository, IUserContext userContext) | ||
{ | ||
_identitiesRepository = identitiesRepository; | ||
_userContext = userContext; | ||
} | ||
|
||
public async Task<IdentityDeletionProcessDTO> Handle(GetDeletionProcessQuery request, CancellationToken cancellationToken) | ||
{ | ||
var identity = await _identitiesRepository.FindByAddress(_userContext.GetAddress(), cancellationToken) ?? throw new NotFoundException(nameof(Identity)); | ||
var deletionProcess = identity.DeletionProcesses.FirstOrDefault(p => p.Id == request.Id) ?? throw new NotFoundException(nameof(IdentityDeletionProcess)); | ||
var response = new IdentityDeletionProcessDTO(deletionProcess); | ||
|
||
return response; | ||
} | ||
} |
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