Generator Changes at 11/16/2025 12:48:45 AM +03:30
This commit is contained in:
@@ -6,8 +6,6 @@ public interface IApplicationDbContext
|
||||
DbSet<Package> Packages { get; }
|
||||
DbSet<Role> Roles { get; }
|
||||
DbSet<UserRole> UserRoles { get; }
|
||||
DbSet<OtpToken> OtpTokens { get; }
|
||||
DbSet<User> Users { get; }
|
||||
DbSet<UserWallet> UserWallets { get; }
|
||||
DbSet<UserWalletChangeLog> UserWalletChangeLogs { get; }
|
||||
DbSet<UserCarts> UserCartss { get; }
|
||||
@@ -17,5 +15,9 @@ public interface IApplicationDbContext
|
||||
DbSet<Products> Productss { get; }
|
||||
DbSet<ProductImages> ProductImagess { get; }
|
||||
DbSet<Transactions> Transactionss { get; }
|
||||
DbSet<User> Users { get; }
|
||||
DbSet<OtpToken> OtpTokens { get; }
|
||||
DbSet<Contract> Contracts { get; }
|
||||
DbSet<UserContract> UserContracts { get; }
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace CMSMicroservice.Application.Common.Mappings;
|
||||
|
||||
public class ContractProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace CMSMicroservice.Application.Common.Mappings;
|
||||
|
||||
public class UserContractProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
|
||||
public record CreateNewContractCommand : IRequest<CreateNewContractResponseDto>
|
||||
{
|
||||
//عنوان
|
||||
public string Title { get; init; }
|
||||
//توضیحات
|
||||
public string Description { get; init; }
|
||||
//متن قرارداد
|
||||
public string HtmlContent { get; init; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
|
||||
public class CreateNewContractCommandHandler : IRequestHandler<CreateNewContractCommand, CreateNewContractResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public CreateNewContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<CreateNewContractResponseDto> Handle(CreateNewContractCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = request.Adapt<Contract>();
|
||||
await _context.Contracts.AddAsync(entity, cancellationToken);
|
||||
entity.AddDomainEvent(new CreateNewContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return entity.Adapt<CreateNewContractResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
|
||||
public class CreateNewContractCommandValidator : AbstractValidator<CreateNewContractCommand>
|
||||
{
|
||||
public CreateNewContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Description)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.HtmlContent)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Type)
|
||||
.IsInEnum()
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewContractCommand>.CreateWithOptions((CreateNewContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
|
||||
public class CreateNewContractResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
|
||||
public record DeleteContractCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
|
||||
public class DeleteContractCommandHandler : IRequestHandler<DeleteContractCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public DeleteContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(DeleteContractCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.Contracts
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Contract), request.Id);
|
||||
entity.IsDeleted = true;
|
||||
_context.Contracts.Update(entity);
|
||||
entity.AddDomainEvent(new DeleteContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
|
||||
public class DeleteContractCommandValidator : AbstractValidator<DeleteContractCommand>
|
||||
{
|
||||
public DeleteContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteContractCommand>.CreateWithOptions((DeleteContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.UpdateContract;
|
||||
public record UpdateContractCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
//عنوان
|
||||
public string Title { get; init; }
|
||||
//توضیحات
|
||||
public string Description { get; init; }
|
||||
//متن قرارداد
|
||||
public string HtmlContent { get; init; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.UpdateContract;
|
||||
public class UpdateContractCommandHandler : IRequestHandler<UpdateContractCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public UpdateContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(UpdateContractCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.Contracts
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Contract), request.Id);
|
||||
request.Adapt(entity);
|
||||
_context.Contracts.Update(entity);
|
||||
entity.AddDomainEvent(new UpdateContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Commands.UpdateContract;
|
||||
public class UpdateContractCommandValidator : AbstractValidator<UpdateContractCommand>
|
||||
{
|
||||
public UpdateContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Description)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.HtmlContent)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Type)
|
||||
.IsInEnum()
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateContractCommand>.CreateWithOptions((UpdateContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.ContractCQ.EventHandlers;
|
||||
|
||||
public class CreateNewContractEventHandler : INotificationHandler<CreateNewContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
CreateNewContractEventHandler> _logger;
|
||||
|
||||
public CreateNewContractEventHandler(ILogger<CreateNewContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(CreateNewContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.ContractCQ.EventHandlers;
|
||||
|
||||
public class DeleteContractEventHandler : INotificationHandler<DeleteContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
DeleteContractEventHandler> _logger;
|
||||
|
||||
public DeleteContractEventHandler(ILogger<DeleteContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(DeleteContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.ContractCQ.EventHandlers;
|
||||
|
||||
public class UpdateContractEventHandler : INotificationHandler<UpdateContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
UpdateContractEventHandler> _logger;
|
||||
|
||||
public UpdateContractEventHandler(ILogger<UpdateContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(UpdateContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
|
||||
public record GetAllContractByFilterQuery : IRequest<GetAllContractByFilterResponseDto>
|
||||
{
|
||||
//موقعیت صفحه بندی
|
||||
public PaginationState? PaginationState { get; init; }
|
||||
//مرتب سازی بر اساس
|
||||
public string? SortBy { get; init; }
|
||||
//فیلتر
|
||||
public GetAllContractByFilterFilter? Filter { get; init; }
|
||||
|
||||
}public class GetAllContractByFilterFilter
|
||||
{
|
||||
//شناسه
|
||||
public long? Id { get; set; }
|
||||
//عنوان
|
||||
public string? Title { get; set; }
|
||||
//توضیحات
|
||||
public string? Description { get; set; }
|
||||
//متن قرارداد
|
||||
public string? HtmlContent { get; set; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
|
||||
public class GetAllContractByFilterQueryHandler : IRequestHandler<GetAllContractByFilterQuery, GetAllContractByFilterResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetAllContractByFilterQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllContractByFilterResponseDto> Handle(GetAllContractByFilterQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = _context.Contracts
|
||||
.ApplyOrder(sortBy: request.SortBy)
|
||||
.AsNoTracking()
|
||||
.AsQueryable();
|
||||
if (request.Filter is not null)
|
||||
{
|
||||
query = query
|
||||
.Where(x => request.Filter.Id == null || x.Id == request.Filter.Id)
|
||||
.Where(x => request.Filter.Title == null || x.Title.Contains(request.Filter.Title))
|
||||
.Where(x => request.Filter.Description == null || x.Description.Contains(request.Filter.Description))
|
||||
.Where(x => request.Filter.HtmlContent == null || x.HtmlContent.Contains(request.Filter.HtmlContent))
|
||||
.Where(x => request.Filter.Type == null || x.Type == request.Filter.Type)
|
||||
;
|
||||
}
|
||||
return new GetAllContractByFilterResponseDto
|
||||
{
|
||||
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||
Models = await query.PaginatedListAsync(paginationState: request.PaginationState)
|
||||
.ProjectToType<GetAllContractByFilterResponseModel>().ToListAsync(cancellationToken)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
|
||||
public class GetAllContractByFilterQueryValidator : AbstractValidator<GetAllContractByFilterQuery>
|
||||
{
|
||||
public GetAllContractByFilterQueryValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllContractByFilterQuery>.CreateWithOptions((GetAllContractByFilterQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
|
||||
public class GetAllContractByFilterResponseDto
|
||||
{
|
||||
//متادیتا
|
||||
public MetaData MetaData { get; set; }
|
||||
//مدل خروجی
|
||||
public List<GetAllContractByFilterResponseModel>? Models { get; set; }
|
||||
|
||||
}public class GetAllContractByFilterResponseModel
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//عنوان
|
||||
public string Title { get; set; }
|
||||
//توضیحات
|
||||
public string Description { get; set; }
|
||||
//متن قرارداد
|
||||
public string HtmlContent { get; set; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetContract;
|
||||
public record GetContractQuery : IRequest<GetContractResponseDto>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetContract;
|
||||
public class GetContractQueryHandler : IRequestHandler<GetContractQuery, GetContractResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetContractQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetContractResponseDto> Handle(GetContractQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.Contracts
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.ProjectToType<GetContractResponseDto>()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return response ?? throw new NotFoundException(nameof(Contract), request.Id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetContract;
|
||||
public class GetContractQueryValidator : AbstractValidator<GetContractQuery>
|
||||
{
|
||||
public GetContractQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetContractQuery>.CreateWithOptions((GetContractQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace CMSMicroservice.Application.ContractCQ.Queries.GetContract;
|
||||
public class GetContractResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//عنوان
|
||||
public string Title { get; set; }
|
||||
//توضیحات
|
||||
public string Description { get; set; }
|
||||
//متن قرارداد
|
||||
public string HtmlContent { get; set; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; set; }
|
||||
|
||||
}
|
||||
@@ -5,7 +5,5 @@ public record CreateNewOtpTokenCommand : IRequest<CreateNewOtpTokenResponseDto>
|
||||
public string Mobile { get; init; }
|
||||
//مقصود
|
||||
public string Purpose { get; init; }
|
||||
//اطلاعات بیشتر
|
||||
public string? ExtraInfo { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
|
||||
public record CreateNewUserContractCommand : IRequest<CreateNewUserContractResponseDto>
|
||||
{
|
||||
//شناسه کاربر
|
||||
public long UserId { get; init; }
|
||||
//شناسه قرارداد
|
||||
public long ContractId { get; init; }
|
||||
//شناسه یکتای امضا
|
||||
public string SignGuid { get; init; }
|
||||
//فایل قرارداد
|
||||
public string SignedPdfFile { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
|
||||
public class CreateNewUserContractCommandHandler : IRequestHandler<CreateNewUserContractCommand, CreateNewUserContractResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public CreateNewUserContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<CreateNewUserContractResponseDto> Handle(CreateNewUserContractCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = request.Adapt<UserContract>();
|
||||
await _context.UserContracts.AddAsync(entity, cancellationToken);
|
||||
entity.AddDomainEvent(new CreateNewUserContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return entity.Adapt<CreateNewUserContractResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
|
||||
public class CreateNewUserContractCommandValidator : AbstractValidator<CreateNewUserContractCommand>
|
||||
{
|
||||
public CreateNewUserContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ContractId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SignGuid)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SignedPdfFile)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewUserContractCommand>.CreateWithOptions((CreateNewUserContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
|
||||
public class CreateNewUserContractResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.DeleteUserContract;
|
||||
public record DeleteUserContractCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.DeleteUserContract;
|
||||
public class DeleteUserContractCommandHandler : IRequestHandler<DeleteUserContractCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public DeleteUserContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(DeleteUserContractCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.UserContracts
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserContract), request.Id);
|
||||
entity.IsDeleted = true;
|
||||
_context.UserContracts.Update(entity);
|
||||
entity.AddDomainEvent(new DeleteUserContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.DeleteUserContract;
|
||||
public class DeleteUserContractCommandValidator : AbstractValidator<DeleteUserContractCommand>
|
||||
{
|
||||
public DeleteUserContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteUserContractCommand>.CreateWithOptions((DeleteUserContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.UpdateUserContract;
|
||||
public record UpdateUserContractCommand : IRequest<Unit>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; init; }
|
||||
//شناسه قرارداد
|
||||
public long ContractId { get; init; }
|
||||
//شناسه یکتای امضا
|
||||
public string SignGuid { get; init; }
|
||||
//فایل قرارداد
|
||||
public string SignedPdfFile { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.UpdateUserContract;
|
||||
public class UpdateUserContractCommandHandler : IRequestHandler<UpdateUserContractCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public UpdateUserContractCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(UpdateUserContractCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.UserContracts
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserContract), request.Id);
|
||||
request.Adapt(entity);
|
||||
_context.UserContracts.Update(entity);
|
||||
entity.AddDomainEvent(new UpdateUserContractEvent(entity));
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Commands.UpdateUserContract;
|
||||
public class UpdateUserContractCommandValidator : AbstractValidator<UpdateUserContractCommand>
|
||||
{
|
||||
public UpdateUserContractCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ContractId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SignGuid)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SignedPdfFile)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateUserContractCommand>.CreateWithOptions((UpdateUserContractCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.UserContractCQ.EventHandlers;
|
||||
|
||||
public class CreateNewUserContractEventHandler : INotificationHandler<CreateNewUserContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
CreateNewUserContractEventHandler> _logger;
|
||||
|
||||
public CreateNewUserContractEventHandler(ILogger<CreateNewUserContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(CreateNewUserContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.UserContractCQ.EventHandlers;
|
||||
|
||||
public class DeleteUserContractEventHandler : INotificationHandler<DeleteUserContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
DeleteUserContractEventHandler> _logger;
|
||||
|
||||
public DeleteUserContractEventHandler(ILogger<DeleteUserContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(DeleteUserContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Domain.Events;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CMSMicroservice.Application.UserContractCQ.EventHandlers;
|
||||
|
||||
public class UpdateUserContractEventHandler : INotificationHandler<UpdateUserContractEvent>
|
||||
{
|
||||
private readonly ILogger<
|
||||
UpdateUserContractEventHandler> _logger;
|
||||
|
||||
public UpdateUserContractEventHandler(ILogger<UpdateUserContractEventHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Handle(UpdateUserContractEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
|
||||
public record GetAllUserContractByFilterQuery : IRequest<GetAllUserContractByFilterResponseDto>
|
||||
{
|
||||
//موقعیت صفحه بندی
|
||||
public PaginationState? PaginationState { get; init; }
|
||||
//مرتب سازی بر اساس
|
||||
public string? SortBy { get; init; }
|
||||
//فیلتر
|
||||
public GetAllUserContractByFilterFilter? Filter { get; init; }
|
||||
|
||||
}public class GetAllUserContractByFilterFilter
|
||||
{
|
||||
//شناسه
|
||||
public long? Id { get; set; }
|
||||
//شناسه کاربر
|
||||
public long? UserId { get; set; }
|
||||
//شناسه قرارداد
|
||||
public long? ContractId { get; set; }
|
||||
//شناسه یکتای امضا
|
||||
public string? SignGuid { get; set; }
|
||||
//فایل قرارداد
|
||||
public string? SignedPdfFile { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
|
||||
public class GetAllUserContractByFilterQueryHandler : IRequestHandler<GetAllUserContractByFilterQuery, GetAllUserContractByFilterResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetAllUserContractByFilterQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllUserContractByFilterResponseDto> Handle(GetAllUserContractByFilterQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = _context.UserContracts
|
||||
.ApplyOrder(sortBy: request.SortBy)
|
||||
.AsNoTracking()
|
||||
.AsQueryable();
|
||||
if (request.Filter is not null)
|
||||
{
|
||||
query = query
|
||||
.Where(x => request.Filter.Id == null || x.Id == request.Filter.Id)
|
||||
.Where(x => request.Filter.UserId == null || x.UserId == request.Filter.UserId)
|
||||
.Where(x => request.Filter.ContractId == null || x.ContractId == request.Filter.ContractId)
|
||||
.Where(x => request.Filter.SignGuid == null || x.SignGuid.Contains(request.Filter.SignGuid))
|
||||
.Where(x => request.Filter.SignedPdfFile == null || x.SignedPdfFile.Contains(request.Filter.SignedPdfFile))
|
||||
;
|
||||
}
|
||||
return new GetAllUserContractByFilterResponseDto
|
||||
{
|
||||
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||
Models = await query.PaginatedListAsync(paginationState: request.PaginationState)
|
||||
.ProjectToType<GetAllUserContractByFilterResponseModel>().ToListAsync(cancellationToken)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
|
||||
public class GetAllUserContractByFilterQueryValidator : AbstractValidator<GetAllUserContractByFilterQuery>
|
||||
{
|
||||
public GetAllUserContractByFilterQueryValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllUserContractByFilterQuery>.CreateWithOptions((GetAllUserContractByFilterQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
|
||||
public class GetAllUserContractByFilterResponseDto
|
||||
{
|
||||
//متادیتا
|
||||
public MetaData MetaData { get; set; }
|
||||
//مدل خروجی
|
||||
public List<GetAllUserContractByFilterResponseModel>? Models { get; set; }
|
||||
|
||||
}public class GetAllUserContractByFilterResponseModel
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
//شناسه قرارداد
|
||||
public long ContractId { get; set; }
|
||||
//شناسه یکتای امضا
|
||||
public string SignGuid { get; set; }
|
||||
//فایل قرارداد
|
||||
public string SignedPdfFile { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
|
||||
public record GetUserContractQuery : IRequest<GetUserContractResponseDto>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
|
||||
public class GetUserContractQueryHandler : IRequestHandler<GetUserContractQuery, GetUserContractResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetUserContractQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserContractResponseDto> Handle(GetUserContractQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.UserContracts
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.ProjectToType<GetUserContractResponseDto>()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return response ?? throw new NotFoundException(nameof(UserContract), request.Id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
|
||||
public class GetUserContractQueryValidator : AbstractValidator<GetUserContractQuery>
|
||||
{
|
||||
public GetUserContractQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetUserContractQuery>.CreateWithOptions((GetUserContractQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
|
||||
public class GetUserContractResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
//شناسه قرارداد
|
||||
public long ContractId { get; set; }
|
||||
//شناسه یکتای امضا
|
||||
public string SignGuid { get; set; }
|
||||
//فایل قرارداد
|
||||
public string SignedPdfFile { get; set; }
|
||||
|
||||
}
|
||||
15
src/CMSMicroservice.Domain/Entities/Contract.cs
Normal file
15
src/CMSMicroservice.Domain/Entities/Contract.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace CMSMicroservice.Domain.Entities;
|
||||
//قراردادها
|
||||
public class Contract : BaseAuditableEntity
|
||||
{
|
||||
//عنوان
|
||||
public string Title { get; set; }
|
||||
//توضیحات
|
||||
public string Description { get; set; }
|
||||
//متن قرارداد
|
||||
public string HtmlContent { get; set; }
|
||||
//نوع قرارداد
|
||||
public UnknownEnumType Type { get; set; }
|
||||
//UserContract Collection Navigation Reference
|
||||
public virtual ICollection<UserContract> UserContracts { get; set; }
|
||||
}
|
||||
@@ -48,4 +48,6 @@ public class User : BaseAuditableEntity
|
||||
public virtual ICollection<UserOrder> UserOrders { get; set; }
|
||||
//User Collection Navigation Reference
|
||||
public virtual ICollection<User> Users { get; set; }
|
||||
//UserContract Collection Navigation Reference
|
||||
public virtual ICollection<UserContract> UserContracts { get; set; }
|
||||
}
|
||||
|
||||
17
src/CMSMicroservice.Domain/Entities/UserContract.cs
Normal file
17
src/CMSMicroservice.Domain/Entities/UserContract.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace CMSMicroservice.Domain.Entities;
|
||||
//قراردادها
|
||||
public class UserContract : BaseAuditableEntity
|
||||
{
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
//User Navigation Property
|
||||
public virtual User User { get; set; }
|
||||
//شناسه قرارداد
|
||||
public long ContractId { get; set; }
|
||||
//Contract Navigation Property
|
||||
public virtual Contract Contract { get; set; }
|
||||
//شناسه یکتای امضا
|
||||
public string SignGuid { get; set; }
|
||||
//فایل قرارداد
|
||||
public string SignedPdfFile { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class CreateNewContractEvent : BaseEvent
|
||||
{
|
||||
public CreateNewContractEvent(Contract item)
|
||||
{
|
||||
}
|
||||
public Contract Item { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class DeleteContractEvent : BaseEvent
|
||||
{
|
||||
public DeleteContractEvent(Contract item)
|
||||
{
|
||||
}
|
||||
public Contract Item { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class UpdateContractEvent : BaseEvent
|
||||
{
|
||||
public UpdateContractEvent(Contract item)
|
||||
{
|
||||
}
|
||||
public Contract Item { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class CreateNewUserContractEvent : BaseEvent
|
||||
{
|
||||
public CreateNewUserContractEvent(UserContract item)
|
||||
{
|
||||
}
|
||||
public UserContract Item { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class DeleteUserContractEvent : BaseEvent
|
||||
{
|
||||
public DeleteUserContractEvent(UserContract item)
|
||||
{
|
||||
}
|
||||
public UserContract Item { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class UpdateUserContractEvent : BaseEvent
|
||||
{
|
||||
public UpdateUserContractEvent(UserContract item)
|
||||
{
|
||||
}
|
||||
public UserContract Item { get; }
|
||||
}
|
||||
@@ -43,8 +43,6 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
||||
public DbSet<Package> Packages => Set<Package>();
|
||||
public DbSet<Role> Roles => Set<Role>();
|
||||
public DbSet<UserRole> UserRoles => Set<UserRole>();
|
||||
public DbSet<OtpToken> OtpTokens => Set<OtpToken>();
|
||||
public DbSet<User> Users => Set<User>();
|
||||
public DbSet<UserWallet> UserWallets => Set<UserWallet>();
|
||||
public DbSet<UserWalletChangeLog> UserWalletChangeLogs => Set<UserWalletChangeLog>();
|
||||
public DbSet<UserCarts> UserCartss => Set<UserCarts>();
|
||||
@@ -54,4 +52,8 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
||||
public DbSet<Products> Productss => Set<Products>();
|
||||
public DbSet<ProductImages> ProductImagess => Set<ProductImages>();
|
||||
public DbSet<Transactions> Transactionss => Set<Transactions>();
|
||||
public DbSet<User> Users => Set<User>();
|
||||
public DbSet<OtpToken> OtpTokens => Set<OtpToken>();
|
||||
public DbSet<Contract> Contracts => Set<Contract>();
|
||||
public DbSet<UserContract> UserContracts => Set<UserContract>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||||
//قراردادها
|
||||
public class ContractConfiguration : IEntityTypeConfiguration<Contract>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Contract> builder)
|
||||
{
|
||||
builder.HasQueryFilter(p => !p.IsDeleted);
|
||||
builder.Ignore(entity => entity.DomainEvents);
|
||||
builder.HasKey(entity => entity.Id);
|
||||
builder.Property(entity => entity.Id).UseIdentityColumn();
|
||||
builder.Property(entity => entity.Title).IsRequired(true);
|
||||
builder.Property(entity => entity.Description).IsRequired(true);
|
||||
builder.Property(entity => entity.HtmlContent).IsRequired(true);
|
||||
builder.Property(entity => entity.Type).IsRequired(true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||||
//قراردادها
|
||||
public class UserContractConfiguration : IEntityTypeConfiguration<UserContract>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserContract> builder)
|
||||
{
|
||||
builder.HasQueryFilter(p => !p.IsDeleted);
|
||||
builder.Ignore(entity => entity.DomainEvents);
|
||||
builder.HasKey(entity => entity.Id);
|
||||
builder.Property(entity => entity.Id).UseIdentityColumn();
|
||||
builder
|
||||
.HasOne(entity => entity.User)
|
||||
.WithMany(entity => entity.UserContracts)
|
||||
.HasForeignKey(entity => entity.UserId)
|
||||
.IsRequired(true);
|
||||
builder
|
||||
.HasOne(entity => entity.Contract)
|
||||
.WithMany(entity => entity.UserContracts)
|
||||
.HasForeignKey(entity => entity.ContractId)
|
||||
.IsRequired(true);
|
||||
builder.Property(entity => entity.SignGuid).IsRequired(true);
|
||||
builder.Property(entity => entity.SignedPdfFile).IsRequired(true);
|
||||
|
||||
}
|
||||
}
|
||||
108
src/CMSMicroservice.Protobuf/Protos/contract.proto
Normal file
108
src/CMSMicroservice.Protobuf/Protos/contract.proto
Normal file
@@ -0,0 +1,108 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package contract;
|
||||
|
||||
import "public_messages.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Contract";
|
||||
|
||||
service ContractContract
|
||||
{
|
||||
rpc CreateNewContract(CreateNewContractRequest) returns (CreateNewContractResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/CreateNewContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc UpdateContract(UpdateContractRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
put: "/UpdateContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeleteContract(DeleteContractRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
delete: "/DeleteContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetContract(GetContractRequest) returns (GetContractResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetContract"
|
||||
|
||||
};
|
||||
};
|
||||
rpc GetAllContractByFilter(GetAllContractByFilterRequest) returns (GetAllContractByFilterResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetAllContractByFilter"
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewContractRequest
|
||||
{
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
string html_content = 3;
|
||||
Unknown type = 4;
|
||||
}
|
||||
message CreateNewContractResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message UpdateContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
string title = 2;
|
||||
string description = 3;
|
||||
string html_content = 4;
|
||||
Unknown type = 5;
|
||||
}
|
||||
message DeleteContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetContractResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
string title = 2;
|
||||
string description = 3;
|
||||
string html_content = 4;
|
||||
Unknown type = 5;
|
||||
}
|
||||
message GetAllContractByFilterRequest
|
||||
{
|
||||
messages.PaginationState pagination_state = 1;
|
||||
google.protobuf.StringValue sort_by = 2;
|
||||
GetAllContractByFilterFilter filter = 3;
|
||||
}
|
||||
message GetAllContractByFilterFilter
|
||||
{
|
||||
google.protobuf.Int64Value id = 1;
|
||||
google.protobuf.StringValue title = 2;
|
||||
google.protobuf.StringValue description = 3;
|
||||
google.protobuf.StringValue html_content = 4;
|
||||
Unknown type = 5;
|
||||
}
|
||||
message GetAllContractByFilterResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated GetAllContractByFilterResponseModel models = 2;
|
||||
}
|
||||
message GetAllContractByFilterResponseModel
|
||||
{
|
||||
int64 id = 1;
|
||||
string title = 2;
|
||||
string description = 3;
|
||||
string html_content = 4;
|
||||
Unknown type = 5;
|
||||
}
|
||||
@@ -36,7 +36,6 @@ message CreateNewOtpTokenRequest
|
||||
{
|
||||
string mobile = 1;
|
||||
string purpose = 2;
|
||||
google.protobuf.StringValue extra_info = 3;
|
||||
}
|
||||
message CreateNewOtpTokenResponse
|
||||
{
|
||||
|
||||
108
src/CMSMicroservice.Protobuf/Protos/usercontract.proto
Normal file
108
src/CMSMicroservice.Protobuf/Protos/usercontract.proto
Normal file
@@ -0,0 +1,108 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package usercontract;
|
||||
|
||||
import "public_messages.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.UserContract";
|
||||
|
||||
service UserContractContract
|
||||
{
|
||||
rpc CreateNewUserContract(CreateNewUserContractRequest) returns (CreateNewUserContractResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/CreateNewUserContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc UpdateUserContract(UpdateUserContractRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
put: "/UpdateUserContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeleteUserContract(DeleteUserContractRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
delete: "/DeleteUserContract"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetUserContract(GetUserContractRequest) returns (GetUserContractResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetUserContract"
|
||||
|
||||
};
|
||||
};
|
||||
rpc GetAllUserContractByFilter(GetAllUserContractByFilterRequest) returns (GetAllUserContractByFilterResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetAllUserContractByFilter"
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewUserContractRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
int64 contract_id = 2;
|
||||
string sign_guid = 3;
|
||||
string signed_pdf_file = 4;
|
||||
}
|
||||
message CreateNewUserContractResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message UpdateUserContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
int64 contract_id = 3;
|
||||
string sign_guid = 4;
|
||||
string signed_pdf_file = 5;
|
||||
}
|
||||
message DeleteUserContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetUserContractRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetUserContractResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
int64 contract_id = 3;
|
||||
string sign_guid = 4;
|
||||
string signed_pdf_file = 5;
|
||||
}
|
||||
message GetAllUserContractByFilterRequest
|
||||
{
|
||||
messages.PaginationState pagination_state = 1;
|
||||
google.protobuf.StringValue sort_by = 2;
|
||||
GetAllUserContractByFilterFilter filter = 3;
|
||||
}
|
||||
message GetAllUserContractByFilterFilter
|
||||
{
|
||||
google.protobuf.Int64Value id = 1;
|
||||
google.protobuf.Int64Value user_id = 2;
|
||||
google.protobuf.Int64Value contract_id = 3;
|
||||
google.protobuf.StringValue sign_guid = 4;
|
||||
google.protobuf.StringValue signed_pdf_file = 5;
|
||||
}
|
||||
message GetAllUserContractByFilterResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated GetAllUserContractByFilterResponseModel models = 2;
|
||||
}
|
||||
message GetAllUserContractByFilterResponseModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
int64 contract_id = 3;
|
||||
string sign_guid = 4;
|
||||
string signed_pdf_file = 5;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Contract;
|
||||
|
||||
public class CreateNewContractRequestValidator : AbstractValidator<CreateNewContractRequest>
|
||||
{
|
||||
public CreateNewContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Description)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.HtmlContent)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Type)
|
||||
.IsInEnum()
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewContractRequest>.CreateWithOptions((CreateNewContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Contract;
|
||||
|
||||
public class DeleteContractRequestValidator : AbstractValidator<DeleteContractRequest>
|
||||
{
|
||||
public DeleteContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteContractRequest>.CreateWithOptions((DeleteContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Contract;
|
||||
|
||||
public class GetAllContractByFilterRequestValidator : AbstractValidator<GetAllContractByFilterRequest>
|
||||
{
|
||||
public GetAllContractByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllContractByFilterRequest>.CreateWithOptions((GetAllContractByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Contract;
|
||||
|
||||
public class GetContractRequestValidator : AbstractValidator<GetContractRequest>
|
||||
{
|
||||
public GetContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetContractRequest>.CreateWithOptions((GetContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Contract;
|
||||
|
||||
public class UpdateContractRequestValidator : AbstractValidator<UpdateContractRequest>
|
||||
{
|
||||
public UpdateContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Description)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.HtmlContent)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Type)
|
||||
.IsInEnum()
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateContractRequest>.CreateWithOptions((UpdateContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.UserContract;
|
||||
|
||||
public class CreateNewUserContractRequestValidator : AbstractValidator<CreateNewUserContractRequest>
|
||||
{
|
||||
public CreateNewUserContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ContractId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SignGuid)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SignedPdfFile)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewUserContractRequest>.CreateWithOptions((CreateNewUserContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.UserContract;
|
||||
|
||||
public class DeleteUserContractRequestValidator : AbstractValidator<DeleteUserContractRequest>
|
||||
{
|
||||
public DeleteUserContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteUserContractRequest>.CreateWithOptions((DeleteUserContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.UserContract;
|
||||
|
||||
public class GetAllUserContractByFilterRequestValidator : AbstractValidator<GetAllUserContractByFilterRequest>
|
||||
{
|
||||
public GetAllUserContractByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllUserContractByFilterRequest>.CreateWithOptions((GetAllUserContractByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.UserContract;
|
||||
|
||||
public class GetUserContractRequestValidator : AbstractValidator<GetUserContractRequest>
|
||||
{
|
||||
public GetUserContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetUserContractRequest>.CreateWithOptions((GetUserContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
namespace CMSMicroservice.Protobuf.Validator.UserContract;
|
||||
|
||||
public class UpdateUserContractRequestValidator : AbstractValidator<UpdateUserContractRequest>
|
||||
{
|
||||
public UpdateUserContractRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.UserId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ContractId)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SignGuid)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SignedPdfFile)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateUserContractRequest>.CreateWithOptions((UpdateUserContractRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||
|
||||
public class ContractProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<Protobuf.Protos.Contract.GetAllContractByFilterRequest, Application.ContractCQ.Queries.GetAllContractByFilter.GetAllContractByFilterQuery>()
|
||||
.IgnoreIf((src, dest) => !src.Filter.HasType, dest => dest.Filter.Type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||
|
||||
public class UserContractProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
37
src/CMSMicroservice.WebApi/Services/ContractService.cs
Normal file
37
src/CMSMicroservice.WebApi/Services/ContractService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Contract;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
|
||||
using CMSMicroservice.Application.ContractCQ.Commands.UpdateContract;
|
||||
using CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
|
||||
using CMSMicroservice.Application.ContractCQ.Queries.GetContract;
|
||||
using CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
public class ContractService : ContractContract.ContractContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public ContractService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
public override async Task<CreateNewContractResponse> CreateNewContract(CreateNewContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<CreateNewContractRequest, CreateNewContractCommand, CreateNewContractResponse>(request, context);
|
||||
}
|
||||
public override async Task<Empty> UpdateContract(UpdateContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<UpdateContractRequest, UpdateContractCommand>(request, context);
|
||||
}
|
||||
public override async Task<Empty> DeleteContract(DeleteContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<DeleteContractRequest, DeleteContractCommand>(request, context);
|
||||
}
|
||||
public override async Task<GetContractResponse> GetContract(GetContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetContractRequest, GetContractQuery, GetContractResponse>(request, context);
|
||||
}
|
||||
public override async Task<GetAllContractByFilterResponse> GetAllContractByFilter(GetAllContractByFilterRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetAllContractByFilterRequest, GetAllContractByFilterQuery, GetAllContractByFilterResponse>(request, context);
|
||||
}
|
||||
}
|
||||
37
src/CMSMicroservice.WebApi/Services/UserContractService.cs
Normal file
37
src/CMSMicroservice.WebApi/Services/UserContractService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
|
||||
using CMSMicroservice.Application.UserContractCQ.Commands.UpdateUserContract;
|
||||
using CMSMicroservice.Application.UserContractCQ.Commands.DeleteUserContract;
|
||||
using CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
|
||||
using CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
public class UserContractService : UserContractContract.UserContractContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public UserContractService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
public override async Task<CreateNewUserContractResponse> CreateNewUserContract(CreateNewUserContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<CreateNewUserContractRequest, CreateNewUserContractCommand, CreateNewUserContractResponse>(request, context);
|
||||
}
|
||||
public override async Task<Empty> UpdateUserContract(UpdateUserContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<UpdateUserContractRequest, UpdateUserContractCommand>(request, context);
|
||||
}
|
||||
public override async Task<Empty> DeleteUserContract(DeleteUserContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<DeleteUserContractRequest, DeleteUserContractCommand>(request, context);
|
||||
}
|
||||
public override async Task<GetUserContractResponse> GetUserContract(GetUserContractRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetUserContractRequest, GetUserContractQuery, GetUserContractResponse>(request, context);
|
||||
}
|
||||
public override async Task<GetAllUserContractByFilterResponse> GetAllUserContractByFilter(GetAllUserContractByFilterRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetAllUserContractByFilterRequest, GetAllUserContractByFilterQuery, GetAllUserContractByFilterResponse>(request, context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user