Update
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole;
|
||||
public record CreateNewUserRoleCommand : IRequest<CreateNewUserRoleResponseDto>
|
||||
{
|
||||
//شناسه نقش
|
||||
public long RoleId { get; init; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; init; }
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole;
|
||||
public class CreateNewUserRoleCommandHandler : IRequestHandler<CreateNewUserRoleCommand, CreateNewUserRoleResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public CreateNewUserRoleCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<CreateNewUserRoleResponseDto> Handle(CreateNewUserRoleCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new CreateNewUserRoleResponseDto();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole;
|
||||
public class CreateNewUserRoleCommandValidator : AbstractValidator<CreateNewUserRoleCommand>
|
||||
{
|
||||
public CreateNewUserRoleCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.RoleId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewUserRoleCommand>.CreateWithOptions((CreateNewUserRoleCommand)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.UserRoleCQ.Commands.CreateNewUserRole;
|
||||
public class CreateNewUserRoleResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole;
|
||||
public record DeleteUserRoleCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole;
|
||||
public class DeleteUserRoleCommandHandler : IRequestHandler<DeleteUserRoleCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public DeleteUserRoleCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(DeleteUserRoleCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new Unit();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole;
|
||||
public class DeleteUserRoleCommandValidator : AbstractValidator<DeleteUserRoleCommand>
|
||||
{
|
||||
public DeleteUserRoleCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteUserRoleCommand>.CreateWithOptions((DeleteUserRoleCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole;
|
||||
public record UpdateUserRoleCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
//شناسه نقش
|
||||
public long RoleId { get; init; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; init; }
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole;
|
||||
public class UpdateUserRoleCommandHandler : IRequestHandler<UpdateUserRoleCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public UpdateUserRoleCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(UpdateUserRoleCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new Unit();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole;
|
||||
public class UpdateUserRoleCommandValidator : AbstractValidator<UpdateUserRoleCommand>
|
||||
{
|
||||
public UpdateUserRoleCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.RoleId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateUserRoleCommand>.CreateWithOptions((UpdateUserRoleCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
|
||||
public record GetAllUserRoleByFilterQuery : IRequest<GetAllUserRoleByFilterResponseDto>
|
||||
{
|
||||
//موقعیت صفحه بندی
|
||||
public PaginationState? PaginationState { get; init; }
|
||||
//مرتب سازی بر اساس
|
||||
public string? SortBy { get; init; }
|
||||
//فیلتر
|
||||
public GetAllUserRoleByFilterFilter? Filter { get; init; }
|
||||
|
||||
}public class GetAllUserRoleByFilterFilter
|
||||
{
|
||||
//شناسه
|
||||
public long? Id { get; set; }
|
||||
//شناسه نقش
|
||||
public long? RoleId { get; set; }
|
||||
//شناسه کاربر
|
||||
public long? UserId { get; set; }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
|
||||
public class GetAllUserRoleByFilterQueryHandler : IRequestHandler<GetAllUserRoleByFilterQuery, GetAllUserRoleByFilterResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetAllUserRoleByFilterQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllUserRoleByFilterResponseDto> Handle(GetAllUserRoleByFilterQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new GetAllUserRoleByFilterResponseDto();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
|
||||
public class GetAllUserRoleByFilterQueryValidator : AbstractValidator<GetAllUserRoleByFilterQuery>
|
||||
{
|
||||
public GetAllUserRoleByFilterQueryValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllUserRoleByFilterQuery>.CreateWithOptions((GetAllUserRoleByFilterQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
|
||||
public class GetAllUserRoleByFilterResponseDto
|
||||
{
|
||||
//متادیتا
|
||||
public MetaData MetaData { get; set; }
|
||||
//مدل خروجی
|
||||
public List<GetAllUserRoleByFilterResponseModel>? Models { get; set; }
|
||||
|
||||
}public class GetAllUserRoleByFilterResponseModel
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//شناسه نقش
|
||||
public long RoleId { get; set; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole;
|
||||
public record GetUserRoleQuery : IRequest<GetUserRoleResponseDto>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole;
|
||||
public class GetUserRoleQueryHandler : IRequestHandler<GetUserRoleQuery, GetUserRoleResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetUserRoleQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserRoleResponseDto> Handle(GetUserRoleQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new GetUserRoleResponseDto();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole;
|
||||
public class GetUserRoleQueryValidator : AbstractValidator<GetUserRoleQuery>
|
||||
{
|
||||
public GetUserRoleQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetUserRoleQuery>.CreateWithOptions((GetUserRoleQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace BackOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole;
|
||||
public class GetUserRoleResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//شناسه نقش
|
||||
public long RoleId { get; set; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user