-
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.
feat: add possibility to query whether an identity was deleted
- Loading branch information
Showing
7 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...les/Devices/src/Devices.Application/Identities/Queries/IsIdentityOfUserDeleted/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,27 @@ | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository; | ||
using Backbone.Modules.Devices.Domain.Entities.Identities; | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Devices.Application.Identities.Queries.IsIdentityOfUserDeleted; | ||
|
||
public class Handler : IRequestHandler<IsIdentityOfUserDeletedQuery, IsIdentityOfUserDeletedResponse> | ||
{ | ||
private readonly IIdentitiesRepository _identitiesRepository; | ||
|
||
public Handler(IIdentitiesRepository identitiesRepository) | ||
{ | ||
_identitiesRepository = identitiesRepository; | ||
} | ||
|
||
public async Task<IsIdentityOfUserDeletedResponse> Handle(IsIdentityOfUserDeletedQuery request, CancellationToken cancellationToken) | ||
{ | ||
var auditLogEntries = await _identitiesRepository.GetIdentityDeletionProcessAuditLogs( | ||
IdentityDeletionProcessAuditLogEntry.BelongsToUser(Username.Parse(request.Username)), | ||
cancellationToken); | ||
|
||
var deletionCompletedAuditLogEntry = auditLogEntries.FirstOrDefault(l => l.MessageKey == MessageKey.DeletionCompleted); | ||
|
||
return new IsIdentityOfUserDeletedResponse(deletionCompletedAuditLogEntry != null, deletionCompletedAuditLogEntry?.CreatedAt); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...es.Application/Identities/Queries/IsIdentityOfUserDeleted/IsIdentityOfUserDeletedQuery.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,13 @@ | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Devices.Application.Identities.Queries.IsIdentityOfUserDeleted; | ||
|
||
public class IsIdentityOfUserDeletedQuery : IRequest<IsIdentityOfUserDeletedResponse> | ||
{ | ||
public IsIdentityOfUserDeletedQuery(string username) | ||
{ | ||
Username = username; | ||
} | ||
|
||
public string Username { get; } | ||
} |
13 changes: 13 additions & 0 deletions
13
...Application/Identities/Queries/IsIdentityOfUserDeleted/IsIdentityOfUserDeletedResponse.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,13 @@ | ||
namespace Backbone.Modules.Devices.Application.Identities.Queries.IsIdentityOfUserDeleted; | ||
|
||
public class IsIdentityOfUserDeletedResponse | ||
{ | ||
public IsIdentityOfUserDeletedResponse(bool isDeleted, DateTime? deletionDate) | ||
{ | ||
IsDeleted = isDeleted; | ||
DeletionDate = deletionDate; | ||
} | ||
|
||
public bool IsDeleted { get; set; } | ||
public DateTime? DeletionDate { get; set; } | ||
} |
13 changes: 13 additions & 0 deletions
13
...s/Devices/src/Devices.Application/Identities/Queries/IsIdentityOfUserDeleted/Validator.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,13 @@ | ||
using Backbone.BuildingBlocks.Application.Extensions; | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
using FluentValidation; | ||
|
||
namespace Backbone.Modules.Devices.Application.Identities.Queries.IsIdentityOfUserDeleted; | ||
|
||
public class Validator : AbstractValidator<IsIdentityOfUserDeletedQuery> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(x => x.Username).ValidId<IsIdentityOfUserDeletedQuery, Username>(); | ||
} | ||
} |
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