Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #7 #9

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions client/MAVN.Service.Kyc.Client/IKycApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ public interface IKycApi
/// <param name="request"></param>
[Put("/api/kyc")]
Task<KycUpdateResponse> UpdateKycInfoAsync([Body] KycUpdateRequest request);

/// <summary>
/// Get current kyc info for list of partners
/// </summary>
/// <param name="partnerIds"></param>
[Post("/api/kyc/list")]
Task<IReadOnlyList<KycInformationResponse>> GetCurrentByPartnerIdsAsync([Body] Guid[] partnerIds);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MAVN.Service.Kyc.Domain.Models;

Expand All @@ -8,6 +9,7 @@ public interface IKycInformationRepository
{
Task AddIfNotExistsAsync(IKycInformation model);
Task UpdateAsync(IKycInformation model);
Task<IKycInformation> GeyByPartnerId(Guid partnerId);
Task<IKycInformation> GetByPartnerId(Guid partnerId);
Task<IReadOnlyList<IKycInformation>> GetByPartnerIds(Guid[] partnerIds);
}
}
1 change: 1 addition & 0 deletions src/MAVN.Service.Kyc.Domain/Services/IKycService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public interface IKycService
Task<UpdateKycStatusErrorCode> UpdateKycInfoAsync(KycInformation model);
Task<IReadOnlyList<IKycInformationStatusChange>> GetKycStatusChangesAsync(Guid partnerId);
Task<IKycInformation> GetCurrentKycStatusAsync(Guid partnerId);
Task<IReadOnlyList<IKycInformation>> GetCurrentKycStatusByPartnerIdsAsync(Guid[] partnerIds);
}
}
7 changes: 5 additions & 2 deletions src/MAVN.Service.Kyc.DomainServices/KycService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task<UpdateKycStatusErrorCode> 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;
Expand Down Expand Up @@ -78,6 +78,9 @@ public Task<IReadOnlyList<IKycInformationStatusChange>> GetKycStatusChangesAsync
=> _kycStatusChangeRepository.GetByPartnerIdAsync(partnerId);

public Task<IKycInformation> GetCurrentKycStatusAsync(Guid partnerId)
=> _kycInformationRepository.GeyByPartnerId(partnerId);
=> _kycInformationRepository.GetByPartnerId(partnerId);

public Task<IReadOnlyList<IKycInformation>> GetCurrentKycStatusByPartnerIdsAsync(Guid[] partnerIds)
=> _kycInformationRepository.GetByPartnerIds(partnerIds);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -54,7 +57,7 @@ public async Task UpdateAsync(IKycInformation model)
}
}

public async Task<IKycInformation> GeyByPartnerId(Guid partnerId)
public async Task<IKycInformation> GetByPartnerId(Guid partnerId)
{
using (var context = _contextFactory.CreateDataContext())
{
Expand All @@ -63,5 +66,17 @@ public async Task<IKycInformation> GeyByPartnerId(Guid partnerId)
return entity;
}
}

public async Task<IReadOnlyList<IKycInformation>> GetByPartnerIds(Guid[] partnerIds)
{
using (var context = _contextFactory.CreateDataContext())
{
var result = await context.KycInformation
.Where(k => partnerIds.Contains(k.PartnerId))
.ToListAsync();

return result;
}
}
}
}
15 changes: 15 additions & 0 deletions src/MAVN.Service.Kyc/Controllers/KycController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Threading.Tasks;
using AutoMapper;
Expand Down Expand Up @@ -39,6 +40,20 @@ public async Task<KycInformationResponse> GetCurrentByPartnerIdAsync([FromQuery]
return _mapper.Map<KycInformationResponse>(result);
}

/// <summary>
/// Get current kyc info for list of partners
/// </summary>
/// <param name="partnerIds"></param>
[HttpPost("list")]
[ProducesResponseType(typeof(KycInformationResponse), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
public async Task<IReadOnlyList<KycInformationResponse>> GetCurrentByPartnerIdsAsync([FromBody][Required] Guid[] partnerIds)
{
var result = await _kycService.GetCurrentKycStatusByPartnerIdsAsync(partnerIds);

return _mapper.Map<IReadOnlyList<KycInformationResponse>>(result);
}

/// <summary>
/// Get history of kyc info
/// </summary>
Expand Down