Generator Changes at 11/12/2025 11:18:31 PM +03:30

This commit is contained in:
masoodafar-web
2025-11-12 23:20:15 +03:30
parent 0adb0713f3
commit 4b1b135065
8 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
namespace CMSMicroservice.Application.UserCQ.Commands.SetPasswordForUser;
public record SetPasswordForUserCommand : IRequest<Unit>
{
//شناسه کاربر
public long UserId { get; init; }
//کلمه عبور فعلی
public string? CurrentPassword { get; init; }
//کلمه عبور
public string NewPassword { get; init; }
//تایید کلمه عبور
public string ConfirmPassword { get; init; }
}

View File

@@ -0,0 +1,17 @@
using CMSMicroservice.Domain.Events;
namespace CMSMicroservice.Application.UserCQ.Commands.SetPasswordForUser;
public class SetPasswordForUserCommandHandler : IRequestHandler<SetPasswordForUserCommand, Unit>
{
private readonly IApplicationDbContext _context;
public SetPasswordForUserCommandHandler(IApplicationDbContext context)
{
_context = context;
}
public async Task<Unit> Handle(SetPasswordForUserCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,20 @@
namespace CMSMicroservice.Application.UserCQ.Commands.SetPasswordForUser;
public class SetPasswordForUserCommandValidator : AbstractValidator<SetPasswordForUserCommand>
{
public SetPasswordForUserCommandValidator()
{
RuleFor(model => model.UserId)
.NotNull();
RuleFor(model => model.NewPassword)
.NotEmpty();
RuleFor(model => model.ConfirmPassword)
.NotEmpty();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<SetPasswordForUserCommand>.CreateWithOptions((SetPasswordForUserCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,22 @@
using CMSMicroservice.Domain.Events;
using Microsoft.Extensions.Logging;
namespace CMSMicroservice.Application.UserCQ.EventHandlers;
public class SetPasswordForUserEventHandler : INotificationHandler<SetPasswordForUserEvent>
{
private readonly ILogger<
SetPasswordForUserEventHandler> _logger;
public SetPasswordForUserEventHandler(ILogger<SetPasswordForUserEventHandler> logger)
{
_logger = logger;
}
public Task Handle(SetPasswordForUserEvent notification, CancellationToken cancellationToken)
{
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
return Task.CompletedTask;
}
}