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

View File

@@ -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; }
}

View File

@@ -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();
}
}

View File

@@ -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);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressResponseDto
{
//شناسه
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public record DeleteUserAddressCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public class DeleteUserAddressCommandHandler : IRequestHandler<DeleteUserAddressCommand, Unit>
{
private readonly IApplicationContractContext _context;
public DeleteUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeleteUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public class DeleteUserAddressCommandValidator : AbstractValidator<DeleteUserAddressCommand>
{
public DeleteUserAddressCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeleteUserAddressCommand>.CreateWithOptions((DeleteUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public record UpdateUserAddressCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
//شناسه کاربر
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; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public class UpdateUserAddressCommandHandler : IRequestHandler<UpdateUserAddressCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdateUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdateUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,28 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public class UpdateUserAddressCommandValidator : AbstractValidator<UpdateUserAddressCommand>
{
public UpdateUserAddressCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
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<UpdateUserAddressCommand>.CreateWithOptions((UpdateUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,27 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public record GetAllUserAddressByFilterQuery : IRequest<GetAllUserAddressByFilterResponseDto>
{
//موقعیت صفحه بندی
public PaginationState? PaginationState { get; init; }
//مرتب سازی بر اساس
public string? SortBy { get; init; }
//فیلتر
public GetAllUserAddressByFilterFilter? Filter { get; init; }
}public class GetAllUserAddressByFilterFilter
{
//شناسه
public long? Id { get; set; }
//شناسه کاربر
public long? UserId { get; set; }
//عنوان
public string? Title { get; set; }
//آدرس
public string? Address { get; set; }
//کدپستی
public string? PostalCode { get; set; }
//پیشفرض؟
public bool? IsDefault { get; set; }
//شناسه شهر
public long? CityId { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterQueryHandler : IRequestHandler<GetAllUserAddressByFilterQuery, GetAllUserAddressByFilterResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllUserAddressByFilterQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllUserAddressByFilterResponseDto> Handle(GetAllUserAddressByFilterQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetAllUserAddressByFilterResponseDto();
}
}

View File

@@ -0,0 +1,14 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterQueryValidator : AbstractValidator<GetAllUserAddressByFilterQuery>
{
public GetAllUserAddressByFilterQueryValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllUserAddressByFilterQuery>.CreateWithOptions((GetAllUserAddressByFilterQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,25 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterResponseDto
{
//متادیتا
public MetaData MetaData { get; set; }
//مدل خروجی
public List<GetAllUserAddressByFilterResponseModel>? Models { get; set; }
}public class GetAllUserAddressByFilterResponseModel
{
//شناسه
public long Id { get; set; }
//شناسه کاربر
public long UserId { get; set; }
//عنوان
public string Title { get; set; }
//آدرس
public string Address { get; set; }
//کدپستی
public string PostalCode { get; set; }
//پیشفرض؟
public bool IsDefault { get; set; }
//شناسه شهر
public long CityId { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public record GetUserAddressQuery : IRequest<GetUserAddressResponseDto>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressQueryHandler : IRequestHandler<GetUserAddressQuery, GetUserAddressResponseDto>
{
private readonly IApplicationContractContext _context;
public GetUserAddressQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetUserAddressResponseDto> Handle(GetUserAddressQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetUserAddressResponseDto();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressQueryValidator : AbstractValidator<GetUserAddressQuery>
{
public GetUserAddressQueryValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetUserAddressQuery>.CreateWithOptions((GetUserAddressQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressResponseDto
{
//شناسه
public long Id { get; set; }
//شناسه کاربر
public long UserId { get; set; }
//عنوان
public string Title { get; set; }
//آدرس
public string Address { get; set; }
//کدپستی
public string PostalCode { get; set; }
//پیشفرض؟
public bool IsDefault { get; set; }
//شناسه شهر
public long CityId { get; set; }
}