Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39d859b8ad | ||
|
|
01c2a04977 | ||
|
|
3d5f2c4953 | ||
|
|
ac93d4da93 | ||
|
|
e494dea3cf | ||
|
|
65ba20c98d | ||
|
|
35683997d1 | ||
|
|
10f5c463db | ||
|
|
221442307e | ||
|
|
3ca3bf05e9 |
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using xDataService.Providers;
|
||||
using xStringService.Constants;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xStringService.Configurations.Entities
|
||||
@@ -9,7 +10,7 @@ namespace xStringService.Configurations.Entities
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<XString> builder)
|
||||
{
|
||||
builder.ToTable("Strings");
|
||||
builder.ToTable(XStringServiceConstants.XStringTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace xStringService.Constants
|
||||
{
|
||||
public struct XStringServiceConstants
|
||||
{
|
||||
//
|
||||
// Service Extensions Log Tag ...
|
||||
public const string XStringServiceDILogTag = "XStringService";
|
||||
|
||||
//
|
||||
// Table Mapping Identifiers ...
|
||||
public const string XStringTable = "Strings";
|
||||
|
||||
//
|
||||
// GraphQL Collection Mappings ...
|
||||
public const string XStringSingleName = "string";
|
||||
public const string XStringCollectionName = "strings";
|
||||
|
||||
//
|
||||
// Hubs ...
|
||||
public const string XStringDtoHub = "stringDto";
|
||||
public const string XStringEntityHub = "stringEntity";
|
||||
|
||||
//
|
||||
// Custome Constants ...
|
||||
|
||||
//
|
||||
// EF Repositories Helper Extensions ...
|
||||
public const string GetXStringEFRepositoryDescriptor = "GetXStringEFRepositoryDescriptor";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xStringService.Controllers
|
||||
{
|
||||
public abstract class XBaseItemResourceProviderControllerBase : XBaseIdentityApiV1Controller, IXBaseItemResourceProviderController
|
||||
{
|
||||
private readonly IXItemResourceProvider provider;
|
||||
|
||||
protected XBaseItemResourceProviderControllerBase(
|
||||
ILogger<XBaseItemResourceProviderControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXItemResourceProvider provider
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages ...
|
||||
/// </summary>
|
||||
/// <param name="identifier">if null or empty, check all languages in Item Side</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Languages")]
|
||||
public virtual async Task<ActionResult<IEnumerable<string>>> GetLanguages(
|
||||
[FromQuery] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
var result = Enumerable.Empty<string>();
|
||||
if (!identifier.IsNull())
|
||||
{
|
||||
//
|
||||
result = await provider.GetLanguages(
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = await provider.GetLanguages(
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource">Specified Resource Title</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ResourceLocales")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XStringDto>>> GetResourceLocales(
|
||||
[FromQuery] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
var result = Enumerable.Empty<XStringDto>();
|
||||
if (!identifier.IsNull())
|
||||
{
|
||||
//
|
||||
result = await provider.GetResourceLocales(
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = await provider.GetResourceLocales(
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Locales/{identifier}")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XLocaleResourceDto>>> GetLocales(
|
||||
[FromRoute] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
|
||||
//
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Language Locale of Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language">if null or empty Remove all Locales</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Locales/{identifier}")]
|
||||
public virtual async Task<ActionResult<XResourceDto>> RemoveLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Connection ID ...
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
XResourceDto result = null;
|
||||
if (!language.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
result = await provider.RemoveLocale(
|
||||
language: language,
|
||||
identifier: identifier,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
await provider.RemoveLocales(
|
||||
identifier: identifier,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified ocale Exists for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Locales/{identifier}/{language}/Has")]
|
||||
public virtual async Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromRoute] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(language)
|
||||
.AddNotNull(identifier)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Calculate Result ...
|
||||
var result = await provider.HasLocale(
|
||||
language: language,
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Locales Representaion based on Specified Identitifer
|
||||
/// as XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resource/{identifier}")]
|
||||
public virtual async Task<ActionResult<XResourceDto>> GetResource(
|
||||
[FromRoute] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
ValidationProvider.NotNull(identifier);
|
||||
|
||||
//
|
||||
var result = await provider.GetResource(
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Locale for Specified Identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Locales/{identifier}")]
|
||||
public virtual async Task<ActionResult<XResourceDto>> AddOrUpdateLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromBody] XLocaleResourceDto locale,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(identifier)
|
||||
.AddNotNull(locale)
|
||||
.AddNotEmpty(locale.Value)
|
||||
.AddNotEmpty(locale.Language)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Retrieve Connection ID ...
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.AddOrUpdateLocale(
|
||||
locale: locale,
|
||||
identifier: identifier,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a Resource State ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resource/{identifier}")]
|
||||
public virtual async Task<ActionResult<XResourceDto>> AddOrUpdateResource(
|
||||
[FromRoute] object identifier,
|
||||
[FromBody] XResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(identifier)
|
||||
.AddNotNull(resource)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Retrieve Connection ID ...
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.AddOrUpdateResource(
|
||||
resource: resource,
|
||||
identifier: identifier,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ using xPushService.Helpers;
|
||||
using xPushService.DI;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Providers;
|
||||
using xStringService.Constants;
|
||||
|
||||
namespace xStringService.DI
|
||||
{
|
||||
@@ -80,8 +81,8 @@ namespace xStringService.DI
|
||||
var pushHelper = new XPushServiceHelper();
|
||||
|
||||
//
|
||||
pushHelper.AddHub<XStringDtoHub>("stringDto");
|
||||
pushHelper.AddHub<XStringEntityHub>("stringEntity");
|
||||
pushHelper.AddHub<XStringDtoHub>(XStringServiceConstants.XStringDtoHub);
|
||||
pushHelper.AddHub<XStringEntityHub>(XStringServiceConstants.XStringEntityHub);
|
||||
|
||||
//
|
||||
app.UseXPushService(pushHelper);
|
||||
@@ -106,7 +107,7 @@ namespace xStringService.DI
|
||||
/// <summary>
|
||||
/// a LogTag for Service ...
|
||||
/// </summary>
|
||||
private static string XLogTag = "XStringService";
|
||||
private static string XLogTag = XStringServiceConstants.XStringServiceDILogTag;
|
||||
|
||||
/// <summary>
|
||||
/// print a log in Console ...
|
||||
@@ -179,9 +180,9 @@ namespace xStringService.DI
|
||||
//
|
||||
descriptor = typeof(XStringServiceHelper)
|
||||
.InvokeGenericMethod<XRepositoryDescriptor>(
|
||||
methodName: "GetXStringEFRepositoryDescriptor",
|
||||
args: null,
|
||||
runtimeType: contextType,
|
||||
args: null
|
||||
methodName: XStringServiceConstants.GetXStringEFRepositoryDescriptor
|
||||
);
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using xDataService.Interfaces;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xStringService.Interfaces
|
||||
namespace xStringService.Interfaces.Entities
|
||||
{
|
||||
public interface IXStringSeeder : IXBaseDbSeeder<XString, int>
|
||||
{}
|
||||
@@ -0,0 +1,117 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xStringService.Interfaces
|
||||
{
|
||||
public interface IXBaseItemResourceProviderController
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages ...
|
||||
/// </summary>
|
||||
/// <param name="identifier">if null or empty, check all languages in Item Side</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Languages")]
|
||||
Task<ActionResult<IEnumerable<string>>> GetLanguages(
|
||||
[FromQuery] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource">Specified Resource Title</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ResourceLocales")]
|
||||
Task<ActionResult<IEnumerable<XStringDto>>> GetResourceLocales(
|
||||
[FromQuery] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Locales/{identifier}")]
|
||||
Task<ActionResult<IEnumerable<XLocaleResourceDto>>> GetLocales(
|
||||
[FromRoute] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Language Locale of Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language">if null or empty Remove all Locales</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Locales/{identifier}")]
|
||||
Task<ActionResult<XResourceDto>> RemoveLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified ocale Exists for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Locales/{identifier}/{language}/Has")]
|
||||
Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromRoute] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Locales Representaion based on Specified Identitifer
|
||||
/// as XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resource/{identifier}")]
|
||||
Task<ActionResult<XResourceDto>> GetResource(
|
||||
[FromRoute] object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Locale for Specified Identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Locales/{identifier}")]
|
||||
Task<ActionResult<XResourceDto>> AddOrUpdateLocale(
|
||||
[FromRoute] object identifier,
|
||||
[FromBody] XLocaleResourceDto locale,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a Resource State ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resource/{identifier}")]
|
||||
Task<ActionResult<XResourceDto>> AddOrUpdateResource(
|
||||
[FromRoute] object identifier,
|
||||
[FromBody] XResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xStringService.Interfaces
|
||||
@@ -8,7 +9,7 @@ namespace xStringService.Interfaces
|
||||
public interface IXItemResourceProvider
|
||||
{
|
||||
//
|
||||
#region All Item Actions ...
|
||||
#region Group Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages for Current Item ...
|
||||
/// </summary>
|
||||
@@ -26,23 +27,23 @@ namespace xStringService.Interfaces
|
||||
Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Exists Locales which Related to this Provider ...
|
||||
/// </summary>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveResourceLocales(
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Single Item Actions ...
|
||||
#region Item Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages for Current Item ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<string>> GetLanguages(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items of type ...
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
@@ -51,6 +52,121 @@ namespace xStringService.Interfaces
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XLocaleResourceDto>> GetLocales(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Locales Representaion based on Specified Identitifer
|
||||
/// as XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> GetResource(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Locale for Specified Identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> AddOrUpdateLocale(
|
||||
object identifier,
|
||||
XLocaleResourceDto locale,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a Resource State ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> AddOrUpdateResource(
|
||||
object identifier,
|
||||
XResourceDto resource,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Language Locale of Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> RemoveLocale(
|
||||
object identifier,
|
||||
string language,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Exists Locales for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveLocales(
|
||||
object identifier,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified ocale Exists for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> HasLocale(
|
||||
object identifier,
|
||||
string language,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Languages for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<string>> GetLanguages(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Resource Title Action ...
|
||||
/// <summary>
|
||||
/// Retrieve Resource Title ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <returns></returns>
|
||||
string GetResourceTitle(object identifier = null);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
@@ -21,7 +20,6 @@ namespace xStringService.Interfaces
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource">Specified Resource Title</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
@@ -83,13 +81,11 @@ namespace xStringService.Interfaces
|
||||
/// Add or Update a Resource Model ...
|
||||
/// </summary>
|
||||
/// <param name="resource">a XResourceDto Model ...</param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> AddOrUpdateResource(
|
||||
XResourceDto resource,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -98,13 +94,11 @@ namespace xStringService.Interfaces
|
||||
/// Add Or Update Locale ...
|
||||
/// </summary>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> AddOrUpdateLocale(
|
||||
XLocaleResourceDto locale,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -113,13 +107,11 @@ namespace xStringService.Interfaces
|
||||
/// Remove Locale ...
|
||||
/// </summary>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XResourceDto> RemoveLocale(
|
||||
XLocaleResourceDto locale,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -128,13 +120,11 @@ namespace xStringService.Interfaces
|
||||
/// Remove Specified Resource Model ...
|
||||
/// </summary>
|
||||
/// <param name="resource">a XResourceDto Model ...</param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveResource(
|
||||
XResourceDto resource,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
using xDataService.Configuration;
|
||||
using xDataService.Interfaces;
|
||||
using xDataService.Providers;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xStringService.Providers
|
||||
namespace xStringService.Providers.Entities
|
||||
{
|
||||
public abstract class XStringSeederBase : XBaseDbSeeder<XString, int>, IXStringSeeder
|
||||
{
|
||||
protected XStringSeederBase(
|
||||
string entity,
|
||||
string database,
|
||||
IXBaseRepository<XString, int> repository,
|
||||
IXStringRepository repository,
|
||||
XDataServiceConfiguration dataServiceConfiguration
|
||||
) : base(
|
||||
entity,
|
||||
@@ -1,5 +1,6 @@
|
||||
using xDataService.Configuration;
|
||||
using xDataService.GraphQL;
|
||||
using xStringService.Constants;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
@@ -14,12 +15,12 @@ namespace xStringService.Providers.GraphQL
|
||||
|
||||
public override string GetInQueryCollectionName()
|
||||
{
|
||||
return "strings";
|
||||
return XStringServiceConstants.XStringCollectionName;
|
||||
}
|
||||
|
||||
public override string GetInQuerySingleName()
|
||||
{
|
||||
return "string";
|
||||
return XStringServiceConstants.XStringSingleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Interfaces.Dtos;
|
||||
using xStringService.Models.Dtos;
|
||||
@@ -13,6 +14,8 @@ namespace xStringService.Providers
|
||||
{
|
||||
public abstract class XBaseItemResourceProvider : IXItemResourceProvider
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
/// <summary>
|
||||
/// Item Name for Resource Providing ...
|
||||
/// </summary>
|
||||
@@ -28,6 +31,7 @@ namespace xStringService.Providers
|
||||
/// String Provider Service ...
|
||||
/// </summary>
|
||||
private readonly IXStringServiceProvider stringProvider;
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
@@ -47,22 +51,20 @@ namespace xStringService.Providers
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region All Item Actions ...
|
||||
#region Group Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages for Current Item ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<string>> GetLanguages(
|
||||
public virtual async Task<IEnumerable<string>> GetLanguages(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
(await GetResourceLocales(cancellationToken))
|
||||
var result = (await ExtractItems(cancellationToken))
|
||||
.Select(x => x.Language)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
.Distinct();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -73,39 +75,416 @@ namespace xStringService.Providers
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
public virtual async Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var identifier = GetResourceTitle();
|
||||
var result = await stringProvider
|
||||
.FindManyAsync(
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder:
|
||||
x => x
|
||||
.OrderBy(y => y.Language)
|
||||
.ThenBy(y => y.ResourceTitle),
|
||||
predicate: x =>
|
||||
x.ResourceTitle.StartsWith(identifier, StringComparison.InvariantCultureIgnoreCase)
|
||||
var result = await ExtractItems(cancellationToken);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Exists Locales which Related to this Provider ...
|
||||
/// </summary>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task RemoveResourceLocales(
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var isDelete = false;
|
||||
XStringDto deleted = null;
|
||||
var items = await ExtractItems(cancellationToken);
|
||||
foreach (var item in items)
|
||||
{
|
||||
//
|
||||
// Check Cancellation ...
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Item ...
|
||||
deleted = await stringProvider.RemoveAsync(
|
||||
id: item.Id,
|
||||
softDelete: false,
|
||||
saveChanges: true,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
// Check Removation Succeed ...
|
||||
isDelete = !deleted.IsNullOrDefault();
|
||||
if (!isDelete)
|
||||
{
|
||||
XException.ActionFailed.Throw();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Item Actions ...
|
||||
/// <summary>
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Retrieve Resource List ...
|
||||
var result = await provider
|
||||
.GetResourceLocales(cancellationToken);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Items for Specified identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<IEnumerable<XLocaleResourceDto>> GetLocales(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Retrieve Resource List ...
|
||||
var result = await provider
|
||||
.GetLocales(cancellationToken);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Locales Representaion based on Specified Identitifer
|
||||
/// as XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> GetResource(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Retrieve Resource List ...
|
||||
var result = await provider
|
||||
.GetResource(cancellationToken);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Locale for Specified Identitifer ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> AddOrUpdateLocale(
|
||||
object identifier,
|
||||
XLocaleResourceDto locale,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!identifier.IsNull() &&
|
||||
!locale.IsNullOrDefault() &&
|
||||
!locale.Value.IsNullOrEmpty() &&
|
||||
!locale.Language.IsNullOrEmpty();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Retrieve Resource List ...
|
||||
var result = await provider
|
||||
.AddOrUpdateLocale(
|
||||
locale: locale,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Single Item Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve a List of Exists Languages for Current Item ...
|
||||
/// Update a Resource State ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> AddOrUpdateResource(
|
||||
object identifier,
|
||||
XResourceDto resource,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Identified Resource Title ...
|
||||
var identifiedResource = GetResourceTitle(identifier);
|
||||
isValid =
|
||||
!resource.IsNullOrDefault() &&
|
||||
(resource.Resource.IsNullOrEmpty() ||
|
||||
resource.Resource == identifiedResource);
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
if (resource.Resource.IsNullOrEmpty())
|
||||
{
|
||||
resource.Resource = identifiedResource;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
// Retrieve Resource List ...
|
||||
var result = await provider
|
||||
.AddOrUpdateResource(
|
||||
resource: resource,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Language Locale of Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> RemoveLocale(
|
||||
object identifier,
|
||||
string language,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!identifier.IsNull() &&
|
||||
!language.IsNullOrEmpty();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Locale Exists ...
|
||||
isValid = await HasLocale(
|
||||
language: language,
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!isValid)
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var locale = (await GetLocales(
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
))
|
||||
.FirstOrDefault(x =>
|
||||
x.Language.Equals(language, StringComparison.InvariantCultureIgnoreCase));
|
||||
isValid = !locale.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
var result = await provider.RemoveLocale(
|
||||
locale: locale,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Exists Locales for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task RemoveLocales(
|
||||
object identifier,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var resource = await GetResource(
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
isValid = !resource.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
await provider.RemoveResource(
|
||||
resource: resource,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified ocale Exists for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> HasLocale(
|
||||
object identifier,
|
||||
string language,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!identifier.IsNull() &&
|
||||
!language.IsNullOrEmpty();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
var result = await provider.HasLocale(
|
||||
language: language,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Exists Languages for Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<string>> GetLanguages(
|
||||
public virtual async Task<IEnumerable<string>> GetLanguages(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -119,48 +498,26 @@ namespace xStringService.Providers
|
||||
}
|
||||
|
||||
//
|
||||
// Set Identifier ...
|
||||
// Setting Resource Title ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
var result =
|
||||
await provider.GetLanguages(cancellationToken);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items of type ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XStringDto>> GetResourceLocales(
|
||||
object identifier,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !identifier.IsNull();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
var result = await provider
|
||||
.GetLanguages(cancellationToken);
|
||||
|
||||
//
|
||||
// Set Identifier ...
|
||||
SetResourceTitle(identifier);
|
||||
|
||||
//
|
||||
var result =
|
||||
await provider.GetResourceLocales(cancellationToken);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Private ...
|
||||
private string GetResourceTitle(object identifier = null)
|
||||
#region Resource Title Action ...
|
||||
/// <summary>
|
||||
/// Retrieve Resource Title ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <returns></returns>
|
||||
public string GetResourceTitle(object identifier = null)
|
||||
{
|
||||
//
|
||||
var result = item;
|
||||
@@ -174,7 +531,14 @@ namespace xStringService.Providers
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Private ...
|
||||
/// <summary>
|
||||
/// Set Resource Title ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
private void SetResourceTitle(object identifier = null)
|
||||
{
|
||||
//
|
||||
@@ -184,6 +548,29 @@ namespace xStringService.Providers
|
||||
value: $"{itemIdentifier}"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// xtract all Items which Belongs to Provider ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<IEnumerable<XStringDto>> ExtractItems(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await stringProvider
|
||||
.FindManyAsync(
|
||||
includeBuilder: null,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.Id),
|
||||
predicate: x =>
|
||||
x.ResourceTitle.StartsWith(
|
||||
item,
|
||||
StringComparison.InvariantCultureIgnoreCase)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Extensions;
|
||||
using xStringService.Interfaces;
|
||||
@@ -181,13 +180,11 @@ namespace xStringService.Providers
|
||||
/// Add or Update a Resource Model ...
|
||||
/// </summary>
|
||||
/// <param name="resource">a XResourceDto Model ...</param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> AddOrUpdateResource(
|
||||
XResourceDto resource,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -209,7 +206,6 @@ namespace xStringService.Providers
|
||||
{
|
||||
await RemoveResource(
|
||||
resource: result,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
@@ -248,7 +244,6 @@ namespace xStringService.Providers
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> AddOrUpdateLocale(
|
||||
XLocaleResourceDto locale,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -297,11 +292,11 @@ namespace xStringService.Providers
|
||||
/// Remove Locale ...
|
||||
/// </summary>
|
||||
/// <param name="locale"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XResourceDto> RemoveLocale(
|
||||
XLocaleResourceDto locale,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -334,17 +329,26 @@ namespace xStringService.Providers
|
||||
/// Remove Specified Resource Model ...
|
||||
/// </summary>
|
||||
/// <param name="resource">a XResourceDto Model ...</param>
|
||||
/// <param name="userInfo">Actor User for Permissions ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task RemoveResource(
|
||||
XResourceDto resource,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Resource ...
|
||||
var isValid =
|
||||
!resource.IsNullOrDefault() &&
|
||||
!resource.Resource.IsNullOrEmpty() &&
|
||||
resource.Resource == this.resource;
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var items = await ExtractItems(cancellationToken);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using xDataService.Interfaces;
|
||||
using xDataService.Providers;
|
||||
using xStringService.Configurations.Entities;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xStringService.Providers
|
||||
@@ -24,6 +25,12 @@ namespace xStringService.Providers
|
||||
/// <param name="modelBuilder"></param>
|
||||
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
||||
{
|
||||
//
|
||||
// Configure Entity Using Provided ...
|
||||
modelBuilder
|
||||
.ApplyConfigurationsFromAssembly(typeof(XStringEntityConfiguration).Assembly);
|
||||
|
||||
//
|
||||
base.ConfigureEntities(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-6
@@ -1,13 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- Runtime Definition -->
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageId>xDashboard.xStringService</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<Authors>Hadi Khazaee Asl</Authors>
|
||||
<Company>SaherElm IT Center</Company>
|
||||
<PackageId>xDashboard.xStringService</PackageId>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
|
||||
<Description>
|
||||
it is a Part of xDashboard on SaherElm IT Center which provides String Resources Futures ...
|
||||
it is a Part of xDashboard on SaherElm IT Center which provides String Resources Futures ...
|
||||
</Description>
|
||||
|
||||
<!-- Icon Definition -->
|
||||
@@ -16,7 +19,8 @@
|
||||
|
||||
<!-- Icon Handling -->
|
||||
<ItemGroup>
|
||||
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
||||
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
||||
PackagePath="\icon.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Local Modules -->
|
||||
@@ -25,8 +29,14 @@
|
||||
|
||||
<!-- Local Dependencies -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
||||
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
||||
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- For XML Documentation Support -->
|
||||
<PropertyGroup>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user