Skip to content

Commit

Permalink
fix review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess committed Oct 8, 2024
1 parent 3544ccd commit 11f1955
Show file tree
Hide file tree
Showing 24 changed files with 922 additions and 388 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/********************************************************************************
* Copyright (c) 2022 BMW Group AG
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand All @@ -18,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public void RemoveAppInstance(Guid appInstanceId) =>
/// <inheritdoc />
public void CreateAppInstanceAssignedServiceAccounts(
IEnumerable<(Guid AppInstanceId, Guid CompanyServiceAccountId)> instanceAccounts) =>
_portalDbContext.AppInstanceAssignedServiceAccounts.AddRange(instanceAccounts
.Select(x => new AppInstanceAssignedCompanyServiceAccount(
_portalDbContext.AppInstanceAssignedTechnicalUsers.AddRange(instanceAccounts
.Select(x => new AppInstanceAssignedTechnicalUser(
x.AppInstanceId,
x.CompanyServiceAccountId)));

Expand All @@ -59,7 +59,7 @@ public Task<bool> CheckInstanceExistsForOffer(Guid offerId) =>

/// <inheritdoc />
public IAsyncEnumerable<Guid> GetAssignedServiceAccounts(Guid appInstanceId) =>
_portalDbContext.AppInstanceAssignedServiceAccounts
_portalDbContext.AppInstanceAssignedTechnicalUsers
.Where(x => x.AppInstanceId == appInstanceId)
.Select(x => x.TechnicalUserId)
.ToAsyncEnumerable();
Expand All @@ -72,6 +72,6 @@ public Task<bool> CheckInstanceHasAssignedSubscriptions(Guid appInstanceId) =>

/// <inheritdoc />
public void RemoveAppInstanceAssignedServiceAccounts(Guid appInstanceId, IEnumerable<Guid> serviceAccountIds) =>
_portalDbContext.AppInstanceAssignedServiceAccounts
.RemoveRange(serviceAccountIds.Select(x => new AppInstanceAssignedCompanyServiceAccount(appInstanceId, x)));
_portalDbContext.AppInstanceAssignedTechnicalUsers
.RemoveRange(serviceAccountIds.Select(x => new AppInstanceAssignedTechnicalUser(appInstanceId, x)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void AttachAndModifyCompanyServiceAccount(
sa.Identity!.IdentityAssignedRoles.Select(r => r.UserRoleId),
sa.Id,
sa.Identity!.UserStatusId,
sa.CompaniesLinkedServiceAccount!.Owners == companyId || sa.CompaniesLinkedServiceAccount!.Provider == companyId,
sa.CompaniesLinkedTechnicalUser!.Owners == companyId || sa.CompaniesLinkedTechnicalUser!.Provider == companyId,
sa.Version,
sa.Connector!.Id,
sa.ClientClientId,
Expand All @@ -127,12 +127,12 @@ public void AttachAndModifyCompanyServiceAccount(
serviceAccount.OfferSubscription,
serviceAccount.Identity!.LastEditor,
serviceAccount.ExternalTechnicalUser,
serviceAccount.CompaniesLinkedServiceAccount
serviceAccount.CompaniesLinkedTechnicalUser
})
.Where(x =>
x.ServiceAccount.Id == serviceAccountId &&
x.Identity!.UserStatusId != UserStatusId.DELETED &&
(x.CompaniesLinkedServiceAccount!.Owners == companyId || x.CompaniesLinkedServiceAccount!.Provider == companyId))
(x.CompaniesLinkedTechnicalUser!.Owners == companyId || x.CompaniesLinkedTechnicalUser!.Provider == companyId))
.Select(x => new CompanyServiceAccountDetailedData(
x.ServiceAccount.Id,
x.ServiceAccount.ClientClientId,
Expand Down Expand Up @@ -184,8 +184,8 @@ public void AttachAndModifyCompanyServiceAccount(
.Select(serviceAccount => new
{
ServiceAccount = serviceAccount,
IsOwner = serviceAccount.CompaniesLinkedServiceAccount!.Owners == userCompanyId,
IsProvider = serviceAccount.CompaniesLinkedServiceAccount!.Provider == userCompanyId
IsOwner = serviceAccount.CompaniesLinkedTechnicalUser!.Owners == userCompanyId,
IsProvider = serviceAccount.CompaniesLinkedTechnicalUser!.Provider == userCompanyId
})
.Where(x =>
(isOwner.HasValue
Expand Down
Loading

0 comments on commit 11f1955

Please sign in to comment.