last ...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xStringService.Interfaces
|
||||
@@ -51,6 +52,15 @@ namespace xStringService.Interfaces
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
Task<string> AddOrUpdateItemResourcer(
|
||||
object identifier,
|
||||
string language,
|
||||
string translation,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Interfaces.Dtos;
|
||||
using xStringService.Models.Dtos;
|
||||
@@ -156,10 +158,71 @@ namespace xStringService.Providers
|
||||
await provider.GetResourceLocales(cancellationToken);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<string> AddOrUpdateItemResourcer(
|
||||
object identifier,
|
||||
string language,
|
||||
string translation,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = string.Empty;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
var isValid =
|
||||
!identifier.IsNull() &&
|
||||
!language.IsNullOrEmpty() &&
|
||||
!translation.IsNullOrEmpty();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Identifier ...
|
||||
var resourceTitle = GetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Set Resource Title ...
|
||||
SetResourceTitle(resourceTitle);
|
||||
|
||||
//
|
||||
// Try to Add Or Update ...
|
||||
var resource = await provider.AddOrUpdateLocale(
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Language = language,
|
||||
Value = translation
|
||||
},
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Result ...
|
||||
isValid = !resource.IsNullOrDefault();
|
||||
if (isValid)
|
||||
{
|
||||
result = resourceTitle;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Private ...
|
||||
/// <summary>
|
||||
/// Retrieve Resource Title ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <returns></returns>
|
||||
private string GetResourceTitle(object identifier = null)
|
||||
{
|
||||
//
|
||||
@@ -175,6 +238,10 @@ namespace xStringService.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set Resource Title ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
private void SetResourceTitle(object identifier = null)
|
||||
{
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user