Skip to content

Commit

Permalink
chore(code-quality): fix imports (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess authored Jul 24, 2024
1 parent f0d4cad commit 53a4369
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 103 deletions.
10 changes: 3 additions & 7 deletions src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
********************************************************************************/

using Microsoft.Extensions.Options;
using Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
Expand All @@ -46,7 +46,6 @@ public class AppsBusinessLogic : IAppsBusinessLogic
private readonly IOfferService _offerService;
private readonly IOfferSetupService _offerSetupService;
private readonly IIdentityData _identityData;
private readonly ILogger<AppsBusinessLogic> _logger;

/// <summary>
/// Constructor.
Expand All @@ -57,22 +56,19 @@ public class AppsBusinessLogic : IAppsBusinessLogic
/// <param name="offerSetupService">Offer Setup Service</param>
/// <param name="settings">Settings</param>
/// <param name="identityService">Identity </param>
/// <param name="logger">The logger</param>
public AppsBusinessLogic(
IPortalRepositories portalRepositories,
IOfferSubscriptionService offerSubscriptionService,
IOfferService offerService,
IOfferSetupService offerSetupService,
IOptions<AppsSettings> settings,
IIdentityService identityService,
ILogger<AppsBusinessLogic> logger)
IIdentityService identityService)
{
_portalRepositories = portalRepositories;
_offerSubscriptionService = offerSubscriptionService;
_offerService = offerService;
_offerSetupService = offerSetupService;
_identityData = identityService.IdentityData;
_logger = logger;
_settings = settings.Value;
}

Expand Down Expand Up @@ -180,7 +176,7 @@ public async Task AddFavouriteAppForUserAsync(Guid appId)
new OfferCompanySubscriptionStatusResponse(
item.OfferId,
item.ServiceName,
item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId, _logger)),
item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId)),
item.Image == Guid.Empty ? null : item.Image)));
}
return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(ConfigureAwaitOptions.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Microsoft.Extensions.Logging;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

namespace Offers.Library.Extensions;
namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions;

public static class CompanySubscriptionStatusExtensions
{
public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this CompanySubscriptionStatusData data, Guid offerId, ILogger logger) =>
public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this CompanySubscriptionStatusData data, Guid offerId) =>
new(
data.CompanyId,
data.CompanyName,
Expand All @@ -34,5 +33,5 @@ public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this Compan
data.BpnNumber,
data.Email,
data.TechnicalUser,
data.ProcessSteps.GetProcessStepTypeId(offerId, logger));
data.ProcessSteps.GetProcessStepTypeId(offerId));
}
24 changes: 15 additions & 9 deletions src/marketplace/Offers.Library/Extensions/ProcessStepExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Microsoft.Extensions.Logging;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Offers.Library.Extensions;
namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions;

public static class ProcessStepExtensions
{
public static ProcessStepTypeId? GetProcessStepTypeId(this IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> processSteps, Guid offerId, ILogger logger)
public static ProcessStepTypeId? GetProcessStepTypeId(this IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> processSteps, Guid offerId)
{
if (processSteps.Count(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO) > 1)
try
{
logger.Log(LogLevel.Error, "Offers: {OfferIds} contain more than one process step in todo", string.Join(",", offerId));
}
var processStep = processSteps.Where(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO)
.DistinctBy(p => p.ProcessStepTypeId)
.SingleOrDefault();

return processSteps.Any(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO)
? processSteps.Single(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO).ProcessStepTypeId
: null;
return processStep == default
? null
: processStep.ProcessStepTypeId;
}
catch (InvalidOperationException)
{
throw new ConflictException($"Offers: {offerId} contains more than one process step in todo");
}
}
}
9 changes: 3 additions & 6 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
********************************************************************************/

using Microsoft.Extensions.Logging;
using Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Async;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Linq;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration;
using Org.Eclipse.TractusX.Portal.Backend.Notifications.Library;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Extensions;
Expand All @@ -45,7 +45,6 @@ public class OfferService : IOfferService
private readonly IMailingProcessCreation _mailingProcessCreation;
private readonly IIdentityData _identityData;
private readonly IOfferSetupService _offerSetupService;
private readonly ILogger<OfferService> _logger;

/// <summary>
/// Constructor.
Expand All @@ -60,15 +59,13 @@ public OfferService(IPortalRepositories portalRepositories,
INotificationService notificationService,
IMailingProcessCreation mailingProcessCreation,
IIdentityService identityService,
IOfferSetupService offerSetupService,
ILogger<OfferService> logger)
IOfferSetupService offerSetupService)
{
_portalRepositories = portalRepositories;
_notificationService = notificationService;
_mailingProcessCreation = mailingProcessCreation;
_identityData = identityService.IdentityData;
_offerSetupService = offerSetupService;
_logger = logger;
}

/// <inheritdoc />
Expand Down Expand Up @@ -828,7 +825,7 @@ public async Task<AppProviderSubscriptionDetailData> GetAppSubscriptionDetailsFo
{
var data = await GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, _portalRepositories.GetInstance<IOfferSubscriptionsRepository>().GetAppSubscriptionDetailsForProviderAsync)
.ConfigureAwait(ConfigureAwaitOptions.None);
return new AppProviderSubscriptionDetailData(data.Id, data.OfferSubscriptionStatus, data.Name, data.Customer, data.Bpn, data.Contact, data.TechnicalUserData, data.TenantUrl, data.AppInstanceId, data.ProcessSteps.GetProcessStepTypeId(data.Id, _logger));
return new AppProviderSubscriptionDetailData(data.Id, data.OfferSubscriptionStatus, data.Name, data.Customer, data.Bpn, data.Contact, data.TechnicalUserData, data.TenantUrl, data.AppInstanceId, data.ProcessSteps.GetProcessStepTypeId(data.Id));
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
********************************************************************************/

using Microsoft.Extensions.Options;
using Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
Expand All @@ -45,7 +45,6 @@ public class ServiceBusinessLogic : IServiceBusinessLogic
private readonly IOfferSetupService _offerSetupService;
private readonly ServiceSettings _settings;
private readonly IIdentityData _identityData;
private readonly ILogger<ServiceBusinessLogic> _logger;

/// <summary>
/// Constructor.
Expand All @@ -56,22 +55,19 @@ public class ServiceBusinessLogic : IServiceBusinessLogic
/// <param name="offerSetupService">Offer Setup Service</param>
/// <param name="identityService">Access the identity of the user</param>
/// <param name="settings">Access to the settings</param>
/// <param name="logger">Access to the logger</param>
public ServiceBusinessLogic(
IPortalRepositories portalRepositories,
IOfferService offerService,
IOfferSubscriptionService offerSubscriptionService,
IOfferSetupService offerSetupService,
IIdentityService identityService,
IOptions<ServiceSettings> settings,
ILogger<ServiceBusinessLogic> logger)
IOptions<ServiceSettings> settings)
{
_portalRepositories = portalRepositories;
_offerService = offerService;
_offerSubscriptionService = offerSubscriptionService;
_offerSetupService = offerSetupService;
_identityData = identityService.IdentityData;
_logger = logger;
_settings = settings.Value;
}

Expand Down Expand Up @@ -156,7 +152,7 @@ public Task<OfferAutoSetupResponseData> AutoSetupServiceAsync(OfferAutoSetupData
new OfferCompanySubscriptionStatusResponse(
item.OfferId,
item.ServiceName,
item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId, _logger)),
item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId)),
item.Image == Guid.Empty ? null : item.Image)));
}
return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(ConfigureAwaitOptions.None);
Expand Down
Loading

0 comments on commit 53a4369

Please sign in to comment.