constellation-api/CH.CQRS/Command/User/UpdateNameCommand.cs

36 lines
921 B
C#
Raw Normal View History

using CH.CQRS.Service.User;
using CH.CQRS.Service.User.Options;
using CH.Dal;
using FluentValidation;
using OpenHarbor.CQRS.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CH.CQRS.Command.User;
public class UpdateNameCommand
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
}
public class UpdateNameCommandHandler(UserService userService) : ICommandHandler<UpdateNameCommand>
{
public Task HandleAsync(UpdateNameCommand command, CancellationToken cancellationToken = default)
{
return userService.UpdateNameAsync(new UpdateNameCommandOptions
{
FirstName = command.FirstName,
LastName = command.LastName,
}, cancellationToken);
}
}
public class UpdateNameCommandValidator : AbstractValidator<UpdateNameCommand>
{
public UpdateNameCommandValidator()
{
}
}