From 4edb4e7e99ccce4f68fa639186283c40a079f6b7 Mon Sep 17 00:00:00 2001 From: Iliyan Iliev Date: Tue, 30 Jun 2020 10:28:09 +0300 Subject: [PATCH] Send KYC notification to PartnerAdmin instead of admin who changed the status --- .../KycService.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/MAVN.Service.Kyc.DomainServices/KycService.cs b/src/MAVN.Service.Kyc.DomainServices/KycService.cs index b6a7229..b82c0cf 100644 --- a/src/MAVN.Service.Kyc.DomainServices/KycService.cs +++ b/src/MAVN.Service.Kyc.DomainServices/KycService.cs @@ -90,29 +90,29 @@ public async Task 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;