Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/aspnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ jobs:
run: dotnet test ./src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj
- name: Grand.SharedKernel.Tests Unit Tests
run: dotnet test ./src/Tests/Grand.SharedKernel.Tests/Grand.SharedKernel.Tests.csproj
- name: Grand.Mapping.Tests Unit Tests
run: dotnet test ./src/Tests/Grand.Mapping.Tests/Grand.Mapping.Tests.csproj
- name: Grand.Web.Common.Tests Unit Tests
run: dotnet test ./src/Tests/Grand.Web.Common.Tests/Grand.Web.Common.Tests.csproj
- name: Grand.Web.Admin.Tests Unit Tests
run: dotnet test ./src/Tests/Grand.Web.Admin.Tests/Grand.Web.Admin.Tests.csproj
- name: Grand.Web.Store.Tests Unit Tests
run: dotnet test ./src/Tests/Grand.Web.Store.Tests/Grand.Web.Store.Tests.csproj
27 changes: 17 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
name: Build and analyze
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
Expand All @@ -18,30 +18,37 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Install .NET Aspire workload
run: dotnet workload install aspire
- name: Cache SonarQube Cloud packages
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~\sonar\cache
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ runner.temp }}\scanner
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path ${{ runner.temp }}\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner
mkdir -p ./.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Start Docker for Mongodb
run: docker run -d -p 27017:27017 mongo
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"grandnode_grandnode2" /o:"grandnode" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
dotnet build
${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
./.sonar/scanner/dotnet-sonarscanner begin /k:"grandnode_grandnode2" /o:"grandnode" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
dotnet build ./GrandNode.sln
dotnet test ./GrandNode.sln --no-build --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
28 changes: 27 additions & 1 deletion GrandNode.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.5.11619.145 insiders
VisualStudioVersion = 18.5.11619.145
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{FA350BD6-C29D-40D9-BA47-FE5FBDFC84A0}"
EndProject
Expand Down Expand Up @@ -149,6 +149,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Web.AdminShared", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Mapping.Tests", "src\Tests\Grand.Mapping.Tests\Grand.Mapping.Tests.csproj", "{396E6929-5365-4116-8AA8-DF5327247798}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{CEA09484-30F6-4D44-02F6-822E06DBC57C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Web.Store.Tests", "src\Tests\Grand.Web.Store.Tests\Grand.Web.Store.Tests.csproj", "{5819B37B-4972-4BBC-B51C-57B0028EF869}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{8D626EA8-CB54-BC41-363A-217881BEBA6E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web", "Web", "{03997797-E7F5-0643-168D-B8EA7178C2FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -891,6 +901,18 @@ Global
{396E6929-5365-4116-8AA8-DF5327247798}.Release|x64.Build.0 = Release|Any CPU
{396E6929-5365-4116-8AA8-DF5327247798}.Release|x86.ActiveCfg = Release|Any CPU
{396E6929-5365-4116-8AA8-DF5327247798}.Release|x86.Build.0 = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|x64.ActiveCfg = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|x64.Build.0 = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|x86.ActiveCfg = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Debug|x86.Build.0 = Debug|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|Any CPU.Build.0 = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|x64.ActiveCfg = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|x64.Build.0 = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|x86.ActiveCfg = Release|Any CPU
{5819B37B-4972-4BBC-B51C-57B0028EF869}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -956,6 +978,10 @@ Global
{136F1E35-8B20-465C-8D42-30A5A0D0DA1F} = {583FFBBD-421C-4FB7-BBDA-F9CAF35A354A}
{12C4A556-E62E-4EC0-BCD9-E9D4E1F3D430} = {BF4543A8-0731-4FDD-BB6B-0ADB9561F981}
{396E6929-5365-4116-8AA8-DF5327247798} = {6360202A-F931-4BBD-ADBD-C9A628EE59F8}
{CEA09484-30F6-4D44-02F6-822E06DBC57C} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{5819B37B-4972-4BBC-B51C-57B0028EF869} = {CEA09484-30F6-4D44-02F6-822E06DBC57C}
{8D626EA8-CB54-BC41-363A-217881BEBA6E} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{03997797-E7F5-0643-168D-B8EA7178C2FE} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88B478F4-FD3B-4C24-9E84-4FAAF0254397}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public virtual async Task<int> GetLoyaltyPointsBalance(string customerId, string
query = query.Where(rph => rph.CustomerId == customerId);
if (!_loyaltyPointsSettings.PointsAccumulatedForAllStores)
query = query.Where(rph => rph.StoreId == storeId);
query = query.OrderByDescending(rph => rph.CreatedOnUtc);
//Id as tie-breaker - entries created within the same millisecond share CreatedOnUtc
query = query.OrderByDescending(rph => rph.CreatedOnUtc).ThenByDescending(rph => rph.Id);

var lastRph = await Task.FromResult(query.FirstOrDefault());
return lastRph?.PointsBalance ?? 0;
Expand Down Expand Up @@ -104,7 +105,7 @@ public virtual async Task<IList<LoyaltyPointsHistory>> GetLoyaltyPointsHistory(s
//filter by store
if (!string.IsNullOrEmpty(storeId))
query = query.Where(rph => rph.StoreId == storeId);
query = query.OrderByDescending(rph => rph.CreatedOnUtc);
query = query.OrderByDescending(rph => rph.CreatedOnUtc).ThenByDescending(rph => rph.Id);

return await Task.FromResult(query.ToList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public virtual async Task<IList<IPaymentProvider>> LoadActivePaymentMethods(Cust
if (selectedShippingOption == null) return await Task.FromResult(pm);
for (var i = pm.Count - 1; i >= 0; i--)
{
var restrictedGroupIds =await GetRestrictedShippingIds(pm[i]);
var restrictedGroupIds =await GetRestrictedShippingIds(pm[i], storeId);
if (restrictedGroupIds.Contains(selectedShippingOption.Name)) pm.Remove(pm[i]);
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public virtual async Task<IList<IPaymentProvider>> LoadAllPaymentMethods(Custome
var filteredPaymentMethods = new List<IPaymentProvider>();
foreach (var pm in paymentMethods)
{
var restrictedCountryIds = await GetRestrictedCountryIds(pm);
var restrictedCountryIds = await GetRestrictedCountryIds(pm, storeId);
if (!restrictedCountryIds.Contains(filterByCountryId))
{
filteredPaymentMethods.Add(pm);
Expand All @@ -123,12 +123,12 @@ public virtual async Task<IList<IPaymentProvider>> LoadAllPaymentMethods(Custome
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <returns>A list of country identifiers</returns>
public virtual async Task<IList<string>> GetRestrictedCountryIds(IPaymentProvider paymentMethod)
public virtual async Task<IList<string>> GetRestrictedCountryIds(IPaymentProvider paymentMethod, string storeId = "")
{
ArgumentNullException.ThrowIfNull(paymentMethod);

var settingKey = $"PaymentMethodRestictions.{paymentMethod.SystemName}";
var restrictedCountryIds = await _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey);
var restrictedCountryIds = await _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey, storeId: storeId);
return restrictedCountryIds == null ? new List<string>() : restrictedCountryIds.Ids;
}

Expand All @@ -137,12 +137,12 @@ public virtual async Task<IList<string>> GetRestrictedCountryIds(IPaymentProvide
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <returns>A list of role identifiers</returns>
public virtual async Task<IList<string>> GetRestrictedShippingIds(IPaymentProvider paymentMethod)
public virtual async Task<IList<string>> GetRestrictedShippingIds(IPaymentProvider paymentMethod, string storeId = "")
{
ArgumentNullException.ThrowIfNull(paymentMethod);

var settingKey = $"PaymentMethodRestictionsShipping.{paymentMethod.SystemName}";
var restrictedShippingIds = await _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey);
var restrictedShippingIds = await _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey, storeId: storeId);
return restrictedShippingIds == null ? new List<string>() : restrictedShippingIds.Ids;
}

Expand All @@ -151,12 +151,12 @@ public virtual async Task<IList<string>> GetRestrictedShippingIds(IPaymentProvid
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="countryIds">A list of country identifiers</param>
public virtual async Task SaveRestrictedCountryIds(IPaymentProvider paymentMethod, List<string> countryIds)
public virtual async Task SaveRestrictedCountryIds(IPaymentProvider paymentMethod, List<string> countryIds, string storeId = "")
{
ArgumentNullException.ThrowIfNull(paymentMethod);

var settingKey = $"PaymentMethodRestictions.{paymentMethod.SystemName}";
await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = countryIds });
await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = countryIds }, storeId);
}

/// <summary>
Expand All @@ -177,12 +177,12 @@ public virtual async Task SaveRestrictedGroupIds(IPaymentProvider paymentMethod,
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="shippingIds">A list of country identifiers</param>
public virtual async Task SaveRestrictedShippingIds(IPaymentProvider paymentMethod, List<string> shippingIds)
public virtual async Task SaveRestrictedShippingIds(IPaymentProvider paymentMethod, List<string> shippingIds, string storeId = "")
{
ArgumentNullException.ThrowIfNull(paymentMethod);

var settingKey = $"PaymentMethodRestictionsShipping.{paymentMethod.SystemName}";
await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = shippingIds });
await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = shippingIds }, storeId);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,33 @@ Task<IList<IPaymentProvider>> LoadAllPaymentMethods(Customer customer = null, st
/// Gets a list of country identifiers in which a certain payment method is now allowed
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="storeId">Store ident; pass "" for the global restriction</param>
/// <returns>A list of country identifiers</returns>
Task<IList<string>> GetRestrictedCountryIds(IPaymentProvider paymentMethod);
Task<IList<string>> GetRestrictedCountryIds(IPaymentProvider paymentMethod, string storeId = "");

/// <summary>
/// Gets a list of shipping identifiers in which a certain payment method is now allowed
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="storeId">Store ident; pass "" for the global restriction</param>
/// <returns>A list of role identifiers</returns>
Task<IList<string>> GetRestrictedShippingIds(IPaymentProvider paymentMethod);
Task<IList<string>> GetRestrictedShippingIds(IPaymentProvider paymentMethod, string storeId = "");

/// <summary>
/// Saves a list of country identifiers in which a certain payment method is now allowed
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="countryIds">A list of country identifiers</param>
Task SaveRestrictedCountryIds(IPaymentProvider paymentMethod, List<string> countryIds);
/// <param name="storeId">Store ident; pass "" for the global restriction</param>
Task SaveRestrictedCountryIds(IPaymentProvider paymentMethod, List<string> countryIds, string storeId = "");

/// <summary>
/// Saves a list of shipping identifiers in which a certain payment method is now allowed
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="shippingIds">A list of shipping identifiers</param>
Task SaveRestrictedShippingIds(IPaymentProvider paymentMethod, List<string> shippingIds);
/// <param name="storeId">Store ident; pass "" for the global restriction</param>
Task SaveRestrictedShippingIds(IPaymentProvider paymentMethod, List<string> shippingIds, string storeId = "");

/// <summary>
/// Process a payment
Expand Down
Loading
Loading