diff --git a/client/MAVN.Service.Kyc.Client/IKycApi.cs b/client/MAVN.Service.Kyc.Client/IKycApi.cs
index bdc2e52..97d72ba 100644
--- a/client/MAVN.Service.Kyc.Client/IKycApi.cs
+++ b/client/MAVN.Service.Kyc.Client/IKycApi.cs
@@ -37,5 +37,12 @@ public interface IKycApi
///
[Put("/api/kyc")]
Task UpdateKycInfoAsync([Body] KycUpdateRequest request);
+
+ ///
+ /// Get current kyc info for list of partners
+ ///
+ ///
+ [Post("/api/kyc/list")]
+ Task> GetCurrentByPartnerIdsAsync([Body] Guid[] partnerIds);
}
}
diff --git a/src/MAVN.Service.Kyc.Domain/Repositories/IKycInformationRepository.cs b/src/MAVN.Service.Kyc.Domain/Repositories/IKycInformationRepository.cs
index c3bd35f..edc3f89 100644
--- a/src/MAVN.Service.Kyc.Domain/Repositories/IKycInformationRepository.cs
+++ b/src/MAVN.Service.Kyc.Domain/Repositories/IKycInformationRepository.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using MAVN.Service.Kyc.Domain.Models;
@@ -8,6 +9,7 @@ public interface IKycInformationRepository
{
Task AddIfNotExistsAsync(IKycInformation model);
Task UpdateAsync(IKycInformation model);
- Task GeyByPartnerId(Guid partnerId);
+ Task GetByPartnerId(Guid partnerId);
+ Task> GetByPartnerIds(Guid[] partnerIds);
}
}
diff --git a/src/MAVN.Service.Kyc.Domain/Services/IKycService.cs b/src/MAVN.Service.Kyc.Domain/Services/IKycService.cs
index a161d9d..f6803a8 100644
--- a/src/MAVN.Service.Kyc.Domain/Services/IKycService.cs
+++ b/src/MAVN.Service.Kyc.Domain/Services/IKycService.cs
@@ -12,5 +12,6 @@ public interface IKycService
Task UpdateKycInfoAsync(KycInformation model);
Task> GetKycStatusChangesAsync(Guid partnerId);
Task GetCurrentKycStatusAsync(Guid partnerId);
+ Task> GetCurrentKycStatusByPartnerIdsAsync(Guid[] partnerIds);
}
}
diff --git a/src/MAVN.Service.Kyc.DomainServices/KycService.cs b/src/MAVN.Service.Kyc.DomainServices/KycService.cs
index 1ab9bd6..22ec58b 100644
--- a/src/MAVN.Service.Kyc.DomainServices/KycService.cs
+++ b/src/MAVN.Service.Kyc.DomainServices/KycService.cs
@@ -42,7 +42,7 @@ public async Task UpdateKycInfoAsync(KycInformation mo
if (model.KycStatus == KycStatus.Rejected && string.IsNullOrEmpty(model.Comment))
return UpdateKycStatusErrorCode.CommentRequired;
- var current = await _kycInformationRepository.GeyByPartnerId(model.PartnerId);
+ var current = await _kycInformationRepository.GetByPartnerId(model.PartnerId);
if (current == null)
return UpdateKycStatusErrorCode.KycDoesNotExist;
@@ -78,6 +78,9 @@ public Task> GetKycStatusChangesAsync
=> _kycStatusChangeRepository.GetByPartnerIdAsync(partnerId);
public Task GetCurrentKycStatusAsync(Guid partnerId)
- => _kycInformationRepository.GeyByPartnerId(partnerId);
+ => _kycInformationRepository.GetByPartnerId(partnerId);
+
+ public Task> GetCurrentKycStatusByPartnerIdsAsync(Guid[] partnerIds)
+ => _kycInformationRepository.GetByPartnerIds(partnerIds);
}
}
diff --git a/src/MAVN.Service.Kyc.MsSqlRepositories/Repositories/KycInformationRepository.cs b/src/MAVN.Service.Kyc.MsSqlRepositories/Repositories/KycInformationRepository.cs
index 64809cf..741f6b1 100644
--- a/src/MAVN.Service.Kyc.MsSqlRepositories/Repositories/KycInformationRepository.cs
+++ b/src/MAVN.Service.Kyc.MsSqlRepositories/Repositories/KycInformationRepository.cs
@@ -1,9 +1,12 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using MAVN.Common.MsSql;
using MAVN.Service.Kyc.Domain.Models;
using MAVN.Service.Kyc.Domain.Repositories;
using MAVN.Service.Kyc.MsSqlRepositories.Entities;
+using Microsoft.EntityFrameworkCore;
namespace MAVN.Service.Kyc.MsSqlRepositories.Repositories
{
@@ -54,7 +57,7 @@ public async Task UpdateAsync(IKycInformation model)
}
}
- public async Task GeyByPartnerId(Guid partnerId)
+ public async Task GetByPartnerId(Guid partnerId)
{
using (var context = _contextFactory.CreateDataContext())
{
@@ -63,5 +66,17 @@ public async Task GeyByPartnerId(Guid partnerId)
return entity;
}
}
+
+ public async Task> GetByPartnerIds(Guid[] partnerIds)
+ {
+ using (var context = _contextFactory.CreateDataContext())
+ {
+ var result = await context.KycInformation
+ .Where(k => partnerIds.Contains(k.PartnerId))
+ .ToListAsync();
+
+ return result;
+ }
+ }
}
}
diff --git a/src/MAVN.Service.Kyc/Controllers/KycController.cs b/src/MAVN.Service.Kyc/Controllers/KycController.cs
index 8fa0cd5..3982f2e 100644
--- a/src/MAVN.Service.Kyc/Controllers/KycController.cs
+++ b/src/MAVN.Service.Kyc/Controllers/KycController.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Threading.Tasks;
using AutoMapper;
@@ -39,6 +40,20 @@ public async Task GetCurrentByPartnerIdAsync([FromQuery]
return _mapper.Map(result);
}
+ ///
+ /// Get current kyc info for list of partners
+ ///
+ ///
+ [HttpPost("list")]
+ [ProducesResponseType(typeof(KycInformationResponse), (int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
+ public async Task> GetCurrentByPartnerIdsAsync([FromBody][Required] Guid[] partnerIds)
+ {
+ var result = await _kycService.GetCurrentKycStatusByPartnerIdsAsync(partnerIds);
+
+ return _mapper.Map>(result);
+ }
+
///
/// Get history of kyc info
///