This commit is contained in:
King
2025-09-28 15:24:13 +03:30
parent 514b3a5975
commit 4241523443
222 changed files with 8139 additions and 0 deletions
@@ -0,0 +1,17 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public record CreateNewUserAddressCommand : IRequest<CreateNewUserAddressResponseDto>
{
//شناسه کاربر
public long UserId { get; init; }
//عنوان
public string Title { get; init; }
//آدرس
public string Address { get; init; }
//کدپستی
public string PostalCode { get; init; }
//پیشفرض؟
public bool IsDefault { get; init; }
//شناسه شهر
public long CityId { get; init; }
}
@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressCommandHandler : IRequestHandler<CreateNewUserAddressCommand, CreateNewUserAddressResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewUserAddressResponseDto> Handle(CreateNewUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new CreateNewUserAddressResponseDto();
}
}
@@ -0,0 +1,26 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressCommandValidator : AbstractValidator<CreateNewUserAddressCommand>
{
public CreateNewUserAddressCommandValidator()
{
RuleFor(model => model.UserId)
.NotNull();
RuleFor(model => model.Title)
.NotEmpty();
RuleFor(model => model.Address)
.NotEmpty();
RuleFor(model => model.PostalCode)
.NotEmpty();
RuleFor(model => model.IsDefault)
.NotNull();
RuleFor(model => model.CityId)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewUserAddressCommand>.CreateWithOptions((CreateNewUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}
@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressResponseDto
{
//شناسه
public long Id { get; set; }
}