Skip to content

Commit

Permalink
fix(service): return the correct lead picture (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhiren-singh-007 authored Aug 8, 2024
1 parent 4ff4a7e commit 028e503
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Task<IEnumerable<ConsentStatusData>> SubmitOfferConsentAsync(Guid appId,
/// <inheritdoc/>
public async Task<AppProviderResponse> 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");
Expand Down
3 changes: 2 additions & 1 deletion src/marketplace/Offers.Library/Service/IOfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId,
/// </summary>
/// <param name="offerId"></param>
/// <param name="offerTypeId"></param>
/// <param name="documentTypeId"></param>
/// <returns></returns>
Task<OfferProviderResponse> GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId);
Task<OfferProviderResponse> GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId);

/// <summary>
/// Checks whether the sales manager has the a sales manager role assigned and is in the same company as the user
Expand Down
4 changes: 2 additions & 2 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ public async Task<Guid> CreateServiceOfferingAsync(ServiceOfferingData data, Off
}

/// <inheritdoc />
public async Task<OfferProviderResponse> GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId)
public async Task<OfferProviderResponse> GetProviderOfferDetailsForStatusAsync(Guid offerId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId)
{
var companyId = _identityData.CompanyId;
var offerDetail = await _portalRepositories.GetInstance<IOfferRepository>().GetProviderOfferDataWithConsentStatusAsync(offerId, companyId, offerTypeId).ConfigureAwait(ConfigureAwaitOptions.None);
var offerDetail = await _portalRepositories.GetInstance<IOfferRepository>().GetProviderOfferDataWithConsentStatusAsync(offerId, companyId, offerTypeId, documentTypeId).ConfigureAwait(ConfigureAwaitOptions.None);
if (offerDetail == default)
{
throw new NotFoundException($"Offer {offerId} does not exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Task<OfferAgreementConsent> GetServiceAgreementConsentAsync(Guid serviceI

public async Task<ServiceProviderResponse> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ public interface IOfferRepository
/// <param name="offerId"></param>
/// <param name="userId"></param>
/// <param name="offerTypeId"></param>
/// <param name="documentTypeId"></param>
/// <returns></returns>
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);

/// <summary>
/// Verify that user is linked to the appId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void RemoveAppLanguages(IEnumerable<(Guid appId, string languageShortName
.SingleOrDefaultAsync();

/// <inheritdoc />
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()
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ public async Task GetAppDetailsForStatusAsync_ReturnsExpected()
// Arrange
var appId = Guid.NewGuid();
var data = _fixture.Create<OfferProviderResponse>();
A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A<Guid>._, A<OfferTypeId>._))
A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A<Guid>._, A<OfferTypeId>._, A<DocumentTypeId>._))
.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);
Expand Down Expand Up @@ -638,7 +638,7 @@ public async Task GetAppDetailsForStatusAsync_NullUseCase_ThrowsUnexpectedCondit
.With(x => x.UseCase, default(IEnumerable<AppUseCaseData>?))
.Create();

A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A<Guid>._, A<OfferTypeId>._))
A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(A<Guid>._, A<OfferTypeId>._, A<DocumentTypeId>._))
.Returns(data);

var Act = () => _sut.GetAppDetailsForStatusAsync(appId);
Expand All @@ -647,7 +647,7 @@ public async Task GetAppDetailsForStatusAsync_NullUseCase_ThrowsUnexpectedCondit
var result = await Assert.ThrowsAsync<UnexpectedConditionException>(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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 028e503

Please sign in to comment.