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

Support for easy add and update to content #21

Merged
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
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;
}
}
}
Loading