Skip to content

Commit

Permalink
chore: remove manual set of lastEditorId
Browse files Browse the repository at this point in the history
Refs: CPLP-2960
  • Loading branch information
Phil91 committed Jul 25, 2023
1 parent 952e01b commit c761c19
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public async Task UploadOfferAssignedAppLeadImageDocumentByIdAsync(Guid appId, (
}

/// <inheritdoc />
public Task DeactivateOfferByAppIdAsync(Guid appId, (Guid UserId, Guid CompanyId) identity) =>
_offerService.DeactivateOfferIdAsync(appId, identity, OfferTypeId.APP);
public Task DeactivateOfferByAppIdAsync(Guid appId, Guid companyId) =>
_offerService.DeactivateOfferIdAsync(appId, companyId, OfferTypeId.APP);

/// <inheritdoc />
public Task UpdateTenantUrlAsync(Guid offerId, Guid subscriptionId, UpdateTenantData data, (Guid UserId, Guid CompanyId) identity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public interface IAppChangeBusinessLogic
/// Deactivate Offer Status by appId
/// </summary>
/// <param name="appId">Id of the app</param>
/// <param name="identity">Users identity</param>
public Task DeactivateOfferByAppIdAsync(Guid appId, (Guid UserId, Guid CompanyId) identity);
/// <param name="companyId">CompanyId</param>
public Task DeactivateOfferByAppIdAsync(Guid appId, Guid companyId);

/// <summary>
/// Updates the url of the subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async Task<NoContentResult> UploadOfferAssignedAppLeadImageDocumentByIdAs
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task<NoContentResult> DeactivateApp([FromRoute] Guid appId)
{
await this.WithUserIdAndCompanyId(identity => _businessLogic.DeactivateOfferByAppIdAsync(appId, identity)).ConfigureAwait(false);
await this.WithCompanyId(companyId => _businessLogic.DeactivateOfferByAppIdAsync(appId, companyId)).ConfigureAwait(false);
return NoContent();
}

Expand Down
4 changes: 2 additions & 2 deletions src/marketplace/Offers.Library/Service/IOfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId,
/// Deactivate the given offerStatus by offerId and offerType
/// </summary>
/// <param name="offerId">Id of the offer that should be Deactivate</param>
/// <param name="identity">Users identity</param>
/// <param name="companyId">CompanyId of the user</param>
/// <param name="offerTypeId">Type of the offer</param>
Task DeactivateOfferIdAsync(Guid offerId, (Guid UserId, Guid CompanyId) identity, OfferTypeId offerTypeId);
Task DeactivateOfferIdAsync(Guid offerId, Guid companyId, OfferTypeId offerTypeId);

/// <summary>
/// Update offer status and create notification for Service
Expand Down
5 changes: 2 additions & 3 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@ private async Task CheckLanguageCodesExist(IEnumerable<string> languageCodes)
}
}

public async Task DeactivateOfferIdAsync(Guid offerId, (Guid UserId, Guid CompanyId) identity, OfferTypeId offerTypeId)
public async Task DeactivateOfferIdAsync(Guid offerId, Guid companyId, OfferTypeId offerTypeId)
{
var offerRepository = _portalRepositories.GetInstance<IOfferRepository>();
var offerData = await offerRepository.GetOfferActiveStatusDataByIdAsync(offerId, offerTypeId, identity.CompanyId).ConfigureAwait(false);
var offerData = await offerRepository.GetOfferActiveStatusDataByIdAsync(offerId, offerTypeId, companyId).ConfigureAwait(false);
if (offerData == default)
{
throw new NotFoundException($"{offerTypeId} {offerId} does not exist.");
Expand All @@ -639,7 +639,6 @@ public async Task DeactivateOfferIdAsync(Guid offerId, (Guid UserId, Guid Compan
{
offer.OfferStatusId = OfferStatusId.INACTIVE;
offer.DateReleased = DateTime.UtcNow;
offer.LastEditorId = identity.UserId;
});
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public interface IServiceChangeBusinessLogic
/// Deactivate Offer Status by serviceId
/// </summary>
/// <param name="serviceId">Id of the service</param>
/// <param name="identity">Users identity</param>
public Task DeactivateOfferByServiceIdAsync(Guid serviceId, (Guid UserId, Guid CompanyId) identity);
/// <param name="companyId">CompanyId of the user</param>
public Task DeactivateOfferByServiceIdAsync(Guid serviceId, Guid companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ServiceChangeBusinessLogic(IOfferService offerService)
}

/// <inheritdoc />
public Task DeactivateOfferByServiceIdAsync(Guid serviceId, (Guid UserId, Guid CompanyId) identity) =>
_offerService.DeactivateOfferIdAsync(serviceId, identity, OfferTypeId.SERVICE);
public Task DeactivateOfferByServiceIdAsync(Guid serviceId, Guid companyId) =>
_offerService.DeactivateOfferIdAsync(serviceId, companyId, OfferTypeId.SERVICE);

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ServiceChangeController(IServiceChangeBusinessLogic serviceChangeBusiness
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task<NoContentResult> DeactivateService([FromRoute] Guid serviceId)
{
await this.WithUserIdAndCompanyId(identity => _serviceChangeBusinessLogic.DeactivateOfferByServiceIdAsync(serviceId, identity)).ConfigureAwait(false);
await this.WithCompanyId(companyId => _serviceChangeBusinessLogic.DeactivateOfferByServiceIdAsync(serviceId, companyId)).ConfigureAwait(false);
return NoContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ public async Task DeactivateOfferStatusbyAppIdAsync_CallsExpected()
var appId = _fixture.Create<Guid>();

// Act
await _sut.DeactivateOfferByAppIdAsync(appId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false);
await _sut.DeactivateOfferByAppIdAsync(appId, _identity.CompanyId).ConfigureAwait(false);

// Assert
A.CallTo(() => _offerService.DeactivateOfferIdAsync(appId, A<ValueTuple<Guid, Guid>>.That.Matches(x => x.Item1 == _identity.UserId && x.Item2 == _identity.CompanyId), OfferTypeId.APP)).MustHaveHappenedOnceExactly();
A.CallTo(() => _offerService.DeactivateOfferIdAsync(appId, _identity.CompanyId, OfferTypeId.APP)).MustHaveHappenedOnceExactly();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task DeactivateApp_ReturnsNoContent()
var result = await this._controller.DeactivateApp(appId).ConfigureAwait(false);

//Assert
A.CallTo(() => _logic.DeactivateOfferByAppIdAsync(appId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId))).MustHaveHappenedOnceExactly();
A.CallTo(() => _logic.DeactivateOfferByAppIdAsync(appId, _identity.CompanyId)).MustHaveHappenedOnceExactly();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ public async Task DeactivateOfferStatusIdAsync_WithoutExistingAppId_ThrowsForbid
.Returns(((bool, bool))default);

// Act
async Task Act() => await _sut.DeactivateOfferIdAsync(notExistingId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId), offerTypeId).ConfigureAwait(false);
async Task Act() => await _sut.DeactivateOfferIdAsync(notExistingId, _identity.CompanyId, offerTypeId).ConfigureAwait(false);

// Assert
var ex = await Assert.ThrowsAsync<NotFoundException>(Act).ConfigureAwait(false);
Expand All @@ -1202,7 +1202,7 @@ public async Task DeactivateOfferStatusIdAsync_WithNotAssignedUser_ThrowsForbidd
.Returns((true, false));

// Act
async Task Act() => await _sut.DeactivateOfferIdAsync(offerId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId), offerTypeId).ConfigureAwait(false);
async Task Act() => await _sut.DeactivateOfferIdAsync(offerId, _identity.CompanyId, offerTypeId).ConfigureAwait(false);

// Assert
var ex = await Assert.ThrowsAsync<ForbiddenException>(Act).ConfigureAwait(false);
Expand All @@ -1221,7 +1221,7 @@ public async Task DeactivateOfferStatusIdAsync_WithNotOfferStatusId_ThrowsConfli
.Returns((false, true));

// Act
async Task Act() => await _sut.DeactivateOfferIdAsync(offerId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId), offerTypeId).ConfigureAwait(false);
async Task Act() => await _sut.DeactivateOfferIdAsync(offerId, _identity.CompanyId, offerTypeId).ConfigureAwait(false);

// Assert
var ex = await Assert.ThrowsAsync<ConflictException>(Act).ConfigureAwait(false);
Expand All @@ -1248,7 +1248,7 @@ public async Task DeactivateOfferStatusIdAsync_WithValidData_CallsExpected(Offer
});

// Act
await _sut.DeactivateOfferIdAsync(offerId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId), offerTypeId).ConfigureAwait(false);
await _sut.DeactivateOfferIdAsync(offerId, _identity.CompanyId, offerTypeId).ConfigureAwait(false);

// Assert
A.CallTo(() => _offerRepository.AttachAndModifyOffer(offerId, A<Action<Offer>>._, A<Action<Offer>?>._)).MustHaveHappenedOnceExactly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public async Task DeactivateOfferByServiceIdAsync_CallsExpected()
// Arrange
var serviceId = _fixture.Create<Guid>();
// Act
await _sut.DeactivateOfferByServiceIdAsync(serviceId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false);
await _sut.DeactivateOfferByServiceIdAsync(serviceId, _identity.CompanyId).ConfigureAwait(false);

// Assert
A.CallTo(() => _offerService.DeactivateOfferIdAsync(serviceId, A<ValueTuple<Guid, Guid>>.That.Matches(x => x.Item1 == _identity.UserId && x.Item2 == _identity.CompanyId), OfferTypeId.SERVICE)).MustHaveHappenedOnceExactly();
A.CallTo(() => _offerService.DeactivateOfferIdAsync(serviceId, _identity.CompanyId, OfferTypeId.SERVICE)).MustHaveHappenedOnceExactly();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task DeactivateApp_ReturnsNoContent()
var result = await this._controller.DeactivateService(serviceId).ConfigureAwait(false);

//Assert
A.CallTo(() => _logic.DeactivateOfferByServiceIdAsync(serviceId, new ValueTuple<Guid, Guid>(_identity.UserId, _identity.CompanyId))).MustHaveHappenedOnceExactly();
A.CallTo(() => _logic.DeactivateOfferByServiceIdAsync(serviceId, _identity.CompanyId)).MustHaveHappenedOnceExactly();
Assert.IsType<NoContentResult>(result);
}
}

0 comments on commit c761c19

Please sign in to comment.