Update
This commit is contained in:
+17
@@ -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; }
|
||||
|
||||
}
|
||||
+16
@@ -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();
|
||||
}
|
||||
}
|
||||
+26
@@ -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);
|
||||
};
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
|
||||
public class CreateNewUserAddressResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user