Skip to content

Commit

Permalink
Merge pull request #21 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Support for easy add and update to content
  • Loading branch information
Ali-YousefiTelori authored Sep 27, 2023
2 parents 6e7f18f + 82f45d4 commit a328d7b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.10</Version>
<Version>0.0.0.11</Version>
<Description>client generated code.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>microservice,Content,Contents,client</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

Expand Down Expand Up @@ -84,5 +85,73 @@ bool IsClass(Type type)
{
return type.GetTypeInfo().IsClass && typeof(string) != type && typeof(char[]) != type;
}

/// <summary>
///
/// </summary>
/// <param name="uniqueRecordId"></param>
/// <param name="name"></param>
/// <param name="languages"></param>
/// <returns></returns>
public async Task<CategoryContractMessageContract> AddToContent(string uniqueRecordId, string name, IEnumerable<LanguageDataContract> languages)
{
var addNames = await _contentClient.AddContentWithKeyAsync(new Contents.GeneratedServices.AddContentWithKeyRequestContract
{
Key = $"{uniqueRecordId}-{name}",
LanguageData = languages.ToList(),
});
return addNames;
}

/// <summary>
///
/// </summary>
/// <param name="items"></param>
/// <returns></returns>
public async Task<CategoryContractMessageContract> AddToContent(params (string UniqueRecordId, string Name, IEnumerable<LanguageDataContract> Languages)[] items)
{
CategoryContractMessageContract result = default;
foreach (var item in items)
{
result = await AddToContent(item.UniqueRecordId, item.Name, item.Languages);
if (!result.IsSuccess)
return result;
}
return result;
}

/// <summary>
///
/// </summary>
/// <param name="uniqueRecordId"></param>
/// <param name="name"></param>
/// <param name="languages"></param>
/// <returns></returns>
public async Task<CategoryContractMessageContract> UpdateToContent(string uniqueRecordId, string name, IEnumerable<LanguageDataContract> languages)
{
var addNames = await _contentClient.AddContentWithKeyAsync(new Contents.GeneratedServices.AddContentWithKeyRequestContract
{
Key = $"{uniqueRecordId}-{name}",
LanguageData = languages.ToList(),
});
return addNames;
}

/// <summary>
///
/// </summary>
/// <param name="items"></param>
/// <returns></returns>
public async Task<CategoryContractMessageContract> UpdateToContent(params (string UniqueRecordId, string Name, IEnumerable<LanguageDataContract> Languages)[] items)
{
CategoryContractMessageContract result = default;
foreach (var item in items)
{
result = await UpdateToContent(item.UniqueRecordId, item.Name, item.Languages);
if (!result.IsSuccess)
return result;
}
return result;
}
}
}

0 comments on commit a328d7b

Please sign in to comment.