Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecommerce common standalone library #1

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ segments_2i
**/CMSModules/WebFarm/*

# Files Generated by this integration
**/App_Data/RepoTemplate/*
**/App_Data/Kentico.Xperience.Ecommerce.Common/*
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"editor.defaultFormatter": "ms-dotnettools.csharp"
},

"dotnet.defaultSolution": "Kentico.Xperience.RepoTemplate.sln",
"dotnet.defaultSolution": "Kentico.Xperience.Ecommerce.Common.sln",

"eslint.workingDirectories": [
"./src/Kentico.Xperience.RepoTemplate/Admin/Client"
"./src/Kentico.Xperience.Ecommerce.Common/Admin/Client"
],

"files.associations": {
Expand Down
20 changes: 10 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{
"type": "npm",
"script": "install",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"path": "src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"group": "clean",
"problemMatcher": [],
"label": "npm: install - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"label": "npm: install - src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"detail": "install dependencies from package"
},
{
Expand All @@ -24,7 +24,7 @@
"problemMatcher": ["$msCompile"],
"group": "none",
"options": {
"cwd": "${workspaceFolder}/src/Kentico.Xperience.RepoTemplate/"
"cwd": "${workspaceFolder}/src/Kentico.Xperience.Ecommerce.Common/"
},
"label": "dotnet: format"
},
Expand All @@ -38,27 +38,27 @@
{
"type": "npm",
"script": "build",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"path": "src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"group": "build",
"problemMatcher": [],
"label": "npm: build - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"label": "npm: build - src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"detail": "webpack --mode=production"
},
{
"type": "npm",
"script": "build:dev",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"path": "src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"group": "build",
"problemMatcher": [],
"label": "npm: build:dev - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"label": "npm: build:dev - src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"detail": "webpack --mode=development"
},
{
"type": "npm",
"script": "start",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"path": "src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"problemMatcher": [],
"label": "npm: start - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"label": "npm: start - src/Kentico.Xperience.Ecommerce.Common/Admin/Client",
"detail": "webpack serve --mode development"
},
{
Expand All @@ -69,7 +69,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/src/Kentico.Xperience.RepoTemplate.Sample/DancingGoat.csproj"
"${workspaceFolder}/src/Kentico.Xperience.Ecommerce.Common.Sample/DancingGoat.csproj"
],
"options": {
"env": {
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<VersionSuffix>prerelease-1</VersionSuffix>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<PackageProjectUrl>https://github.com/Kentico/REPOSITORY_NAME</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/Kentico/REPOSITORY_NAME/releases</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/Kentico/xperience-by-kentico-ecommerce-common</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/Kentico/xperience-by-kentico-ecommerce-common/releases</PackageReleaseNotes>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>xperience;kentico;aspnetcore</PackageTags>
Expand All @@ -30,7 +30,7 @@
<CopyDocumentationFilesFromPackages>true</CopyDocumentationFilesFromPackages>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<NoWarn>$(NoWarn);1591</NoWarn>
<RootNamespace>Kentico.Xperience.RepoTemplate</RootNamespace>
<RootNamespace>Kentico.Xperience.Ecommerce.Common</RootNamespace>

<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<TimestampServerUrl>http://timestamp.digicert.com</TimestampServerUrl>
Expand Down
6 changes: 2 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Kentico.Xperience.Admin" Version="28.4.2" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="28.4.2" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="28.4.2" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="28.4.2" />
<PackageVersion Include="Kentico.Xperience.Core" Version="28.2.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.23.0.88079" />
</ItemGroup>
</Project>
43 changes: 43 additions & 0 deletions Kentico.Xperience.Ecommerce.Common.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kentico.Xperience.Ecommerce.Common", "src\Kentico.Xperience.Ecommerce.Common\Kentico.Xperience.Ecommerce.Common.csproj", "{0A775ADD-E5FB-4E81-ABF1-A7689476E788}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{22D98C99-36D2-4591-BF21-B29393898DDF}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
.markdownlint.json = .markdownlint.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{12AA74B2-41DB-4CAD-AE3D-CB8188B5702B}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.build.targets = Directory.build.targets
Directory.Packages.props = Directory.Packages.props
global.json = global.json
nuget.config = nuget.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0A775ADD-E5FB-4E81-ABF1-A7689476E788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A775ADD-E5FB-4E81-ABF1-A7689476E788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A775ADD-E5FB-4E81-ABF1-A7689476E788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A775ADD-E5FB-4E81-ABF1-A7689476E788}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1B2A20BC-F57B-4AAE-B1C2-E4DC52EFCAC5}
EndGlobalSection
EndGlobal
19 changes: 0 additions & 19 deletions Kentico.Xperience.RepoTemplate.sln

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# ---Package Name---
# Xperience by Kentico - E-Commerce common

---Select the correct badge for the support policy and update the GitHub Action pipeline badge to point to this repository (replace `repo-template`)---

[![7-day bug-fix policy](https://img.shields.io/badge/-7--days_bug--fixing_policy-grey?labelColor=orange&logo=data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3ZnLWljb24iIHN0eWxlPSJ3aWR0aDogMWVtOyBoZWlnaHQ6IDFlbTt2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO2ZpbGw6IGN1cnJlbnRDb2xvcjtvdmVyZmxvdzogaGlkZGVuOyIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik04ODguNDkgMjIyLjY4NnYtMzEuNTRsLTY1LjY3Mi0wLjk1NWgtMC4yMDVhNDY1LjcxNSA0NjUuNzE1IDAgMCAxLTE0NC4zMTUtMzEuMzM0Yy03Ny4wMDUtMzEuMTk4LTEyNi4yOTQtNjYuNzY1LTEyNi43MDMtNjcuMTA3bC0zOS44LTI4LjY3Mi0zOS4xODUgMjguNDY4Yy0yLjA0OCAxLjUwMS00OS45MDMgMzYuMDQ0LTEyNi45MDggNjcuMzFhNDQ3LjQyIDQ0Ny40MiAwIDAgMS0xNDQuNTIgMzEuMzM1bC02NS44NzcgMC45NTZ2Mzc4Ljg4YzAgODcuMDQgNDkuODM0IDE4NC42NjEgMTM3LjAxIDI2Ny44MSAzNy41NDcgMzUuODQgNzkuMjU4IDY2LjM1NSAxMjAuODMzIDg4LjIgNDMuMjggMjIuNzMzIDg0LjI0IDM0LjYxMiAxMTguODUyIDM0LjYxMiAzNC40MDYgMCA3NS43NzYtMTIuMTUyIDExOS42MDMtMzUuMTU4YTU0Ny45NzcgNTQ3Ljk3NyAwIDAgMCAxMjAuMDEzLTg3LjY1NCA1MTUuMjA5IDUxNS4yMDkgMCAwIDAgOTYuMTg4LTEyMi44OGMyNy4xMDItNDkuN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labelColor=orange&logo=data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3ZnLWljb24iIHN0eWxlPSJ3aWR0aDogMWVtOyBoZWlnaHQ6IDFlbTt2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO2ZpbGw6IGN1cnJlbnRDb2xvcjtvdmVyZmxvdzogaGlkZGVuOyIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik05NTYuMjg4IDgwNC40OEw2NDAgMjc3LjQ0VjY0aDMyYzE3LjYgMCAzMi0xNC40IDMyLTMycy0xNC40LTMyLTMyLTMyaC0zMjBjLTE3LjYgMC0zMiAxNC40LTMyIDMyczE0LjQgMzIgMzIgMzJIMzg0djIxMy40NEw2Ny43MTIgODA0LjQ4Qy00LjczNiA5MjUuMTg0IDUxLjIgMTAyNCAxOTIgMTAyNGg2NDBjMTQwLjggMCAxOTYuNzM2LTk4Ljc1MiAxMjQuMjg4LTIxOS41MnpNMjQxLjAyNCA2NDBMNDQ4IDI5NS4wNFY2NGgxMjh2MjMxLjA0TDc4Mi45NzYgNjQwSDI0MS4wMjR6IiAgLz48L3N2Zz4=)](https://github.com/Kentico/.github/blob/main/SUPPORT.md#labs-limited-support) [![CI: Build and Test](https://github.com/Kentico/repo-template/actions/workflows/ci.yml/badge.svg)](https://github.com/Kentico/repo-template/actions/workflows/ci.yml)

---Remove/replace all lines surrounded by 3 dashes---
[![7-day bug-fix policy](https://img.shields.io/badge/-7--days_bug--fixing_policy-grey?labelColor=orange&logo=data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3ZnLWljb24iIHN0eWxlPSJ3aWR0aDogMWVtOyBoZWlnaHQ6IDFlbTt2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO2ZpbGw6IGN1cnJlbnRDb2xvcjtvdmVyZmxvdzogaGlkZGVuOyIgdmlld0JveD0iMCAwIDE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IyMS40NTdDNjQxLjU3IDg1NC4yODkgNTYzLjEzIDg5Ni40NzggNTEyIDg5Ni40NzhjLTIzLjY4OSAwLTU1LjU3LTkuODk5LTg5LjcwMi0yNy43ODVhNDc4LjgyMiA0NzguODIyIDAgMCAxLTEwNS42MDktNzcuMjc4QzI0Mi4yMSA3MjAuMjEzIDE5OS40NzUgNjM5LjUyMiAxOTkuNDc1IDU2OS44OVYyNTQuMjI1bDIuNzMtMC4xMzZjMy4yNzggMCA4Mi42MDQtMS41MDIgMTY3LjY2NC0zNS45NzdhNzM5Ljk0MiA3MzkuOTQyIDAgMCAwIDE0MC4yMi03NC42MTV2LTAuMDY5eiIgIC8+PHBhdGggZD0iTTcxMy4zMTggMzY4LjY0YTMyLjIyMiAzMi4yMjIgMCAwIDAtNDUuMzI5IDBMNDQ5LjE5NSA1ODcuNDM1bC05My4xODQtOTMuMTE2YTMyLjIyMiAzMi4yMjIgMCAwIDAtNDUuMzMgMCAzMi4yMjIgMzIuMjIyIDAgMCAwIDAgNDUuMjZsMTE1Ljg1IDExNS44NWEzMi4yOSAzMi4yOSAwIDAgMCA0NS4zMjggMEw3MTMuMzIgNDEzLjlhMzIuMjIyIDMyLjIyMiAwIDAgMCAwLTQ1LjMzeiIgIC8+PC9zdmc+)](https://github.com/Kentico/.github/blob/main/SUPPORT.md#full-support)
[![CI: Build and Test](https://github.com/Kentico/repo-template/actions/workflows/ci.yml/badge.svg)](https://github.com/Kentico/repo-template/actions/workflows/ci.yml)

## Description

Expand All @@ -20,7 +19,7 @@

| Xperience Version | Library Version |
| ----------------- | --------------- |
| >= 28.1.0 | 1.0.0 |
| >= 28.2.1 | 1.0.0 |

### Dependencies

Expand All @@ -36,7 +35,7 @@
Add the package to your application using the .NET CLI

```powershell
dotnet add package Kentico.Xperience.RepoTemplate
dotnet add package Kentico.Xperience.Ecommerce.Common
```

## Quick Start
Expand Down
6 changes: 3 additions & 3 deletions docs/Contributing-Setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing Setup

---This documents the steps a maintainer or developer would follow to work on the library in their development environment---
---Update the details for this project, replacing "repotemplate" and anything else that needs changed---
---Update the details for this project, replacing "Ecommerce.Common" and anything else that needs changed---

## Required Software

Expand Down Expand Up @@ -53,7 +53,7 @@ To run the Sample app Admin customization in development mode, add the following

```json
"CMSAdminClientModuleSettings": {
"kentico-xperience-integrations-repotemplate": {
"kentico-xperience-integrations-Ecommerce.Common": {
martinfbluesoftcz marked this conversation as resolved.
Show resolved Hide resolved
"Mode": "Proxy",
"Port": 3009
}
Expand All @@ -68,7 +68,7 @@ To run the Sample app Admin customization in development mode, add the following
- `refactor/` - for restructuring of existing features
- `fix/` - for bugfixes

1. Run `dotnet format` against the `src/Kentico.Xperience.RepoTemplate` project
1. Run `dotnet format` against the `src/Kentico.Xperience.Ecommerce.Common` project

> use `dotnet: format` VS Code task.

Expand Down
Empty file removed src/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Kentico.Xperience.Ecommerce.Common.ContentItemSynchronization;

/// <summary>
/// Interface for synchronized content items.
/// </summary>
public class ContentItemAddParams
{
public required ContentItemSynchronizationBase ContentItem { get; set; }

public required string LanguageName { get; set; }

public int UserID { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using CMS.ContentEngine;

namespace Kentico.Xperience.Ecommerce.Common.ContentItemSynchronization;

/// <summary>
/// Service for content items management
/// </summary>
public class ContentItemServiceBase : IContentItemService
michalJakubis marked this conversation as resolved.
Show resolved Hide resolved
{
protected readonly IContentItemManagerFactory ContentItemManagerFactory;

protected readonly IContentQueryExecutor ContentQueryExecutor;

protected readonly IContentQueryResultMapper ContentQueryResultMapper;


public ContentItemServiceBase(
IContentItemManagerFactory contentItemManagerFactory,
IContentQueryExecutor contentQueryExecutor,
IContentQueryResultMapper contentQueryResultMapper)
{
ContentItemManagerFactory = contentItemManagerFactory;
ContentQueryExecutor = contentQueryExecutor;
ContentQueryResultMapper = contentQueryResultMapper;
}


public async Task<int> AddContentItem(ContentItemAddParams addParams)
martinfbluesoftcz marked this conversation as resolved.
Show resolved Hide resolved
{
ArgumentNullException.ThrowIfNull(addParams);

var createParams = new CreateContentItemParameters(
addParams.ContentItem.ContentTypeName,
addParams.ContentItem.GenerateCodeName(),
addParams.ContentItem.DisplayName,
addParams.LanguageName);
var itemData = new ContentItemData(addParams.ContentItem.ToDict());

var contentItemManager = ContentItemManagerFactory.Create(addParams.UserID);
int itemID = await contentItemManager.Create(createParams, itemData);
await contentItemManager.TryPublish(itemID, addParams.LanguageName);

return itemID;
}


public async Task<bool> UpdateContentItem(ContentItemUpdateParams updateParams)
{
var contentItemManager = ContentItemManagerFactory.Create(updateParams.UserID);
var versionStatus = updateParams.VersionStatus;

// If content item version is not draft, create draft in order to edit it
if (versionStatus != VersionStatus.Draft &&
versionStatus != VersionStatus.InitialDraft &&
!await contentItemManager.TryCreateDraft(updateParams.ContentItemID, updateParams.LanguageName))
{
return false;
}

var itemData = new ContentItemData(updateParams.ContentItemParams);
if (!await contentItemManager.TryUpdateDraft(updateParams.ContentItemID, updateParams.LanguageName, itemData))
{
return false;
}

return versionStatus switch
{
VersionStatus.Published => await contentItemManager.TryPublish(updateParams.ContentItemID, updateParams.LanguageName),
VersionStatus.Archived => await contentItemManager.TryArchive(updateParams.ContentItemID, updateParams.LanguageName),
VersionStatus.InitialDraft => true,
VersionStatus.Draft => true,
_ => true,
};
}


public async Task<IEnumerable<T>> GetContentItems<T>(string contentType, Action<ContentTypeQueryParameters> queryParams)
where T : IContentItemFieldsSource, new()
{
var builder = new ContentItemQueryBuilder()
.ForContentType(contentType, queryParams);

return await ContentQueryExecutor.GetResult(builder, ContentQueryResultMapper.Map<T>);
}


public async Task<IEnumerable<T>> GetContentItems<T>(string contentType)
where T : IContentItemFieldsSource, new() => await GetContentItems<T>(contentType, 0);


public async Task<IEnumerable<T>> GetContentItems<T>(string contentType, int linkedItemsLevel)
where T : IContentItemFieldsSource, new()
{
var builder = new ContentItemQueryBuilder()
.ForContentType(contentType, config => config.WithLinkedItems(linkedItemsLevel));

return await ContentQueryExecutor.GetResult(builder, ContentQueryResultMapper.Map<T>);
}


public async Task DeleteContentItem(int contentItemID, string languageName, int userID)
{
var contentItemManager = ContentItemManagerFactory.Create(userID);
await contentItemManager.Delete(contentItemID, languageName);
}


public async Task DeleteContentItems(IEnumerable<int> contentItemIDs, string languageName, int userID)
{
if (!contentItemIDs.Any())
{
return;
}

var contentItemManager = ContentItemManagerFactory.Create(userID);

foreach (int contentItemID in contentItemIDs)
{
await contentItemManager.Delete(contentItemID, languageName);
}
}
}

Loading
Loading