From 028e50377e3646a81c57daa2500c39221969e16c Mon Sep 17 00:00:00 2001 From: "Dhirender Singh (Cofinity-X)" <144212607+dhiren-singh-007@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:59:46 +0200 Subject: [PATCH] fix(service): return the correct lead picture (#904) --- .../Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs | 2 +- src/marketplace/Offers.Library/Service/IOfferService.cs | 3 ++- src/marketplace/Offers.Library/Service/OfferService.cs | 4 ++-- .../BusinessLogic/ServiceReleaseBusinessLogic.cs | 2 +- .../Repositories/IOfferRepository.cs | 3 ++- .../Repositories/OfferRepository.cs | 4 ++-- .../BusinessLogic/AppReleaseBusinessLogicTest.cs | 8 ++++---- .../BusinessLogic/ServiceReleaseBusinessLogicTest.cs | 2 +- .../PortalBackend.DBAccess.Tests/OfferRepositoryTests.cs | 6 +++--- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs index 2e5914d16f..9a86e2ae74 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs @@ -124,7 +124,7 @@ public Task> SubmitOfferConsentAsync(Guid appId, /// public async Task GetAppDetailsForStatusAsync(Guid appId) { - var result = await _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP).ConfigureAwait(ConfigureAwaitOptions.None); + var result = await _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE).ConfigureAwait(ConfigureAwaitOptions.None); if (result.UseCase == null) { throw new UnexpectedConditionException("usecase should never be null here"); diff --git a/src/marketplace/Offers.Library/Service/IOfferService.cs b/src/marketplace/Offers.Library/Service/IOfferService.cs index c48b40d762..edce3661c1 100644 --- a/src/marketplace/Offers.Library/Service/IOfferService.cs +++ b/src/marketplace/Offers.Library/Service/IOfferService.cs @@ -104,8 +104,9 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId, /// /// /// + /// /// - Task GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId); + Task GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId); /// /// Checks whether the sales manager has the a sales manager role assigned and is in the same company as the user diff --git a/src/marketplace/Offers.Library/Service/OfferService.cs b/src/marketplace/Offers.Library/Service/OfferService.cs index 73d31435d2..bc6a5acd23 100644 --- a/src/marketplace/Offers.Library/Service/OfferService.cs +++ b/src/marketplace/Offers.Library/Service/OfferService.cs @@ -267,10 +267,10 @@ public async Task CreateServiceOfferingAsync(ServiceOfferingData data, Off } /// - public async Task GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId) + public async Task GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId) { var companyId = _identityData.CompanyId; - var offerDetail = await _portalRepositories.GetInstance().GetProviderOfferDataWithConsentStatusAsync(offerId, companyId, offerTypeId).ConfigureAwait(ConfigureAwaitOptions.None); + var offerDetail = await _portalRepositories.GetInstance().GetProviderOfferDataWithConsentStatusAsync(offerId, companyId, offerTypeId, documentTypeId).ConfigureAwait(ConfigureAwaitOptions.None); if (offerDetail == default) { throw new NotFoundException($"Offer {offerId} does not exist"); diff --git a/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs index 30a4a76a9d..1c0be97985 100644 --- a/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs @@ -105,7 +105,7 @@ public Task GetServiceAgreementConsentAsync(Guid serviceI public async Task GetServiceDetailsForStatusAsync(Guid serviceId) { - var result = await _offerService.GetProviderOfferDetailsForStatusAsync(serviceId, OfferTypeId.SERVICE).ConfigureAwait(ConfigureAwaitOptions.None); + var result = await _offerService.GetProviderOfferDetailsForStatusAsync(serviceId, OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE).ConfigureAwait(ConfigureAwaitOptions.None); if (result.ServiceTypeIds == null) { throw new UnexpectedConditionException("serviceTypeIds should never be null here"); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferRepository.cs index bc46e99b9a..5ed720665e 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferRepository.cs @@ -176,8 +176,9 @@ public interface IOfferRepository /// /// /// + /// /// - Task<(OfferProviderData? OfferProviderData, bool IsProviderCompanyUser)> GetProviderOfferDataWithConsentStatusAsync(Guid offerId, Guid userCompanyId, OfferTypeId offerTypeId); + Task<(OfferProviderData? OfferProviderData, bool IsProviderCompanyUser)> GetProviderOfferDataWithConsentStatusAsync(Guid offerId, Guid userCompanyId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId); /// /// Verify that user is linked to the appId diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferRepository.cs index 6fc0ecc174..d4d27cec83 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferRepository.cs @@ -341,7 +341,7 @@ public void RemoveAppLanguages(IEnumerable<(Guid appId, string languageShortName .SingleOrDefaultAsync(); /// - public Task<(OfferProviderData? OfferProviderData, bool IsProviderCompanyUser)> GetProviderOfferDataWithConsentStatusAsync(Guid offerId, Guid userCompanyId, OfferTypeId offerTypeId) => + public Task<(OfferProviderData? OfferProviderData, bool IsProviderCompanyUser)> GetProviderOfferDataWithConsentStatusAsync(Guid offerId, Guid userCompanyId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId) => _context.Offers .AsNoTracking() .AsSplitQuery() @@ -356,7 +356,7 @@ public void RemoveAppLanguages(IEnumerable<(Guid appId, string languageShortName ? new OfferProviderData( x.Offer.Name, x.Offer.Provider, - x.Offer.Documents.Where(document => document.DocumentTypeId == DocumentTypeId.APP_LEADIMAGE && document.DocumentStatusId != DocumentStatusId.INACTIVE).Select(document => document.Id).FirstOrDefault(), + x.Offer.Documents.Where(document => document.DocumentTypeId == documentTypeId && document.DocumentStatusId != DocumentStatusId.INACTIVE).Select(document => document.Id).FirstOrDefault(), x.Offer.ProviderCompany!.Name, offerTypeId == OfferTypeId.APP ? x.Offer.UseCases.Select(uc => new AppUseCaseData(uc.Id, uc.Name)) diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs index 436180017d..6c846dc548 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs @@ -601,14 +601,14 @@ public async Task GetAppDetailsForStatusAsync_ReturnsExpected() // Arrange var appId = Guid.NewGuid(); var data = _fixture.Create(); - A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A._, A._)) + A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A._, A._, A._)) .Returns(data); // Act var result = await _sut.GetAppDetailsForStatusAsync(appId); // Assert - A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP)) + A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE)) .MustHaveHappenedOnceExactly(); result.Title.Should().Be(data.Title); @@ -638,7 +638,7 @@ public async Task GetAppDetailsForStatusAsync_NullUseCase_ThrowsUnexpectedCondit .With(x => x.UseCase, default(IEnumerable?)) .Create(); - A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A._, A._)) + A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A._, A._, A._)) .Returns(data); var Act = () => _sut.GetAppDetailsForStatusAsync(appId); @@ -647,7 +647,7 @@ public async Task GetAppDetailsForStatusAsync_NullUseCase_ThrowsUnexpectedCondit var result = await Assert.ThrowsAsync(Act); // Assert - A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP)) + A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(appId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE)) .MustHaveHappenedOnceExactly(); result.Message.Should().Be("usecase should never be null here"); diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs index 5dbd9ec39b..d78467bf90 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs @@ -257,7 +257,7 @@ public async Task GetServiceTypeDataAsync_ReturnsExpected() .With(x => x.ServiceTypeIds, new[] { ServiceTypeId.DATASPACE_SERVICE, ServiceTypeId.CONSULTANCY_SERVICE }) .Create(); - A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(serviceId, OfferTypeId.SERVICE)) + A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(serviceId, OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE)) .Returns(data); var result = await _sut.GetServiceDetailsForStatusAsync(serviceId); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferRepositoryTests.cs index 5f831e4423..e56563cf2e 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferRepositoryTests.cs @@ -473,7 +473,7 @@ public async Task GetProviderOfferDataWithConsentStatusAsync_APP_ReturnsExpected var sut = await CreateSut(); // Act - var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007"), _userCompanyId, OfferTypeId.APP); + var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007"), _userCompanyId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE); // Assert result.IsProviderCompanyUser.Should().BeTrue(); @@ -492,7 +492,7 @@ public async Task GetProviderOfferDataWithConsentStatusAsync_APP_InvalidUser_Ret var sut = await CreateSut(); // Act - var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007"), Guid.NewGuid(), OfferTypeId.APP); + var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007"), Guid.NewGuid(), OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE); // Assert result.IsProviderCompanyUser.Should().BeFalse(); @@ -506,7 +506,7 @@ public async Task GetProviderOfferDataWithConsentStatusAsync_SERVICE_ReturnsExpe var sut = await CreateSut(); // Act - var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0000c0001"), _userCompanyId, OfferTypeId.SERVICE); + var result = await sut.GetProviderOfferDataWithConsentStatusAsync(new Guid("ac1cf001-7fbc-1f2f-817f-bce0000c0001"), _userCompanyId, OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE); // Assert result.IsProviderCompanyUser.Should().BeTrue();