Skip to content

Commit

Permalink
Merge pull request #12 from IliyanIlievPH/master
Browse files Browse the repository at this point in the history
Send KYC notification to PartnerAdmin instead of admin who changed th…
  • Loading branch information
IliyanIlievPH committed Jun 30, 2020
2 parents e543d90 + 4edb4e7 commit 76b0ead
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/MAVN.Service.Kyc.DomainServices/KycService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,29 @@ public async Task<UpdateKycStatusErrorCode> UpdateKycInfoAsync(KycInformation mo
if (model.KycStatus != KycStatus.Accepted && model.KycStatus != KycStatus.Rejected)
return UpdateKycStatusErrorCode.None;

var admin = await _adminManagementClient.AdminsApi.GetByIdAsync(
new GetAdminByIdRequestModel { AdminUserId = model.AdminUserId.ToString() });
var partner = await _partnerManagementClient.Partners.GetByIdAsync(model.PartnerId);

if (admin.Error != AdminUserResponseErrorCodes.None || admin.Profile == null)
if (partner == null)
{
_log.Warning("Missing admin when trying to send KYC notification", context: model.AdminUserId);
_log.Warning("Missing partner when trying to send KYC notification", context: model.PartnerId);
return UpdateKycStatusErrorCode.None;
}

var partner = await _partnerManagementClient.Partners.GetByIdAsync(model.PartnerId);
var admin = await _adminManagementClient.AdminsApi.GetByIdAsync(
new GetAdminByIdRequestModel { AdminUserId = partner.CreatedBy.ToString() });

if (partner == null)
if (admin.Error != AdminUserResponseErrorCodes.None || admin.Profile == null)
{
_log.Warning("Missing partner when trying to send KYC notification", context: model.PartnerId);
_log.Warning("Missing admin when trying to send KYC notification", context: new { PartnerAdminId = partner.CreatedBy });
return UpdateKycStatusErrorCode.None;
}

if (model.KycStatus == KycStatus.Accepted)
await _notificationsService.NotifyKycApprovedAsync(model.AdminUserId.ToString(),
await _notificationsService.NotifyKycApprovedAsync(admin.Profile.AdminUserId,
admin.Profile.Email,
admin.Profile.FirstName, partner.Name);
else
await _notificationsService.NotifyKycRejectedAsync(model.AdminUserId.ToString(),
await _notificationsService.NotifyKycRejectedAsync(admin.Profile.AdminUserId,
admin.Profile.Email, admin.Profile.FirstName, partner.Name, model.Comment);

return UpdateKycStatusErrorCode.None;
Expand Down

0 comments on commit 76b0ead

Please sign in to comment.