diff --git a/Controllers/XBaseStringResourceProviderControllerBase.cs b/Controllers/XBaseStringResourceProviderControllerBase.cs deleted file mode 100644 index 07b3875..0000000 --- a/Controllers/XBaseStringResourceProviderControllerBase.cs +++ /dev/null @@ -1,387 +0,0 @@ -using System; -using System.Collections.Generic; -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.Base; -using xModels.Dtos; -using xStringService.Interfaces; -using xStringService.Models.Dtos; - -namespace xStringService.Controllers -{ - /// - /// an Implementation of Base Actions of a Controller which Provides - /// XString Resource Service Actions ... - /// - public abstract class XBaseStringResourceProviderControllerBase : XBaseIdentityApiV1Controller, IXBaseStringResourceProviderControllerBase - { - private readonly IXBaseStringResourceProvider resourceProvider; - - protected XBaseStringResourceProviderControllerBase( - ILogger logger, - XAppConfiguration appConfiguration, - IXIdentityProvider identityProvider, - XValidationProvider validationProvider, - IXBaseStringResourceProvider resourceProvider - ) : base( - logger, - appConfiguration, - identityProvider, - validationProvider - ) - { - this.resourceProvider = resourceProvider; - } - - /// - /// Add Specified Locales ... - /// - /// - /// - /// - /// - [HttpPost("Add")] - public virtual async Task>> Add( - [FromQuery] string suffix, - [FromBody] XBaseRangeRequest locales, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(suffix) - .AddNotNull(locales) - .AddNotZeroChilds(locales.Items) - .ValidateGroupAsync(); - - // - var connectionId = GetConnectionId(); - - // - var result = await resourceProvider.Add( - suffix: suffix, - locales: locales.Items, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - - // - return Ok(result.ToDynamicObject()); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Add or Update Specified Locales ... - /// - /// - /// - /// - /// - [HttpPost("AddOrUpdate")] - public virtual async Task>> AddOrUpdate( - [FromQuery] string resource, - [FromBody] XBaseRangeRequest locales, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(resource) - .AddNotNull(locales) - .AddNotZeroChilds(locales.Items) - .ValidateGroupAsync(); - - // - var connectionId = GetConnectionId(); - - // - var result = await resourceProvider.AddOrUpdate( - resource: resource, - locales: locales.Items, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - - // - return Ok(result.ToDynamicObject()); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Add Specified Resource ... - /// - /// - /// - /// - /// - [HttpPost("AddResource")] - public virtual async Task> AddResource( - [FromQuery] string suffix, - [FromBody] XResourceDto item, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(suffix) - .AddNotNull(item) - .AddNotZeroChilds(item.Locales) - .ValidateGroupAsync(); - - // - var connectionId = GetConnectionId(); - - // - var result = await resourceProvider.AddResource( - item: item, - suffix: suffix, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - - // - return Ok(result.ToDynamicObject()); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Get Specified Locale ... - /// - /// - /// - /// - /// - [HttpGet("GetLocale")] - public virtual async Task> GetLocale( - [FromQuery] string suffix, - [FromQuery] string language = null, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(suffix) - .ValidateGroupAsync(); - - // - var result = await resourceProvider.GetLocale( - suffix: suffix, - language: language, - cancellationToken: cancellationToken - ); - - // - return Ok(result.ToDynamicObject()); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Get Resources of Specified Resource Title ... - /// - /// - /// - /// - [HttpGet("GetResource")] - public virtual async Task> GetResource( - [FromQuery] string suffix, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(suffix) - .ValidateGroupAsync(); - - // - var result = await resourceProvider.GetResource( - suffix: suffix, - cancellationToken: cancellationToken - ); - - // - return Ok(result.ToDynamicObject()); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Remove all Resources which belongs to Specified Suffix ... - /// - /// - /// - /// - [HttpDelete("Remove")] - public virtual async Task Remove( - [FromQuery] string suffix, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(suffix) - .ValidateGroupAsync(); - - // - var connectionId = GetConnectionId(); - - // - await resourceProvider.Remove( - suffix: suffix, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - - // - return Ok(); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - - /// - /// Remove Specified Resource ... - /// - /// - /// - /// - /// - [HttpDelete("RemoveResource")] - public virtual async Task Remove( - [FromQuery] string resource, - [FromQuery] string language, - CancellationToken cancellationToken = default - ) - { - // - try - { - // - // Validate ... - if (!ModelState.IsValid) - { - XException.InvalidArgs.Throw(); - } - await ValidationProvider - .GroupValidationBuilder() - .AddNotEmpty(resource) - .AddNotEmpty(language) - .ValidateGroupAsync(); - - // - var connectionId = GetConnectionId(); - - // - await resourceProvider.Remove( - resource: resource, - language: language, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - - // - return Ok(); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - } -} \ No newline at end of file diff --git a/Interfaces/IXBaseStringResourceProvider.cs b/Interfaces/IXBaseStringResourceProvider.cs deleted file mode 100644 index 444832a..0000000 --- a/Interfaces/IXBaseStringResourceProvider.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using xCommons.Configurations; -using xModels.Dtos; -using xStringService.Interfaces.Dtos; -using xStringService.Models.Dtos; - -namespace xStringService.Interfaces -{ - /// - /// a Base Class for Handling Resources Based on Specified Types on - /// String Resources Use ... - /// such as: - /// - Terms and Conditions; - /// - Contents; - /// - News; - /// - etc ... - /// - public interface IXBaseStringResourceProvider - { - // - #region Props ... - string Prefix { get; } - IXStringServiceProvider Provider { get; } - XAppConfiguration AppConfiguration { get; } - #endregion - - // - #region Actions ... - /// - /// Prepare Resource Title by Given Data ... - /// - /// - /// - string GetResourceTitle(string suffix); - - /// - /// Add Specified Locales ... - /// - /// - /// - /// - /// - /// - Task> Add( - string suffix, - IEnumerable locales, - string connectionId = null, - CancellationToken cancellationToken = default - ); - - /// - /// Add Or Update Specified Locals ... - /// - /// - /// - /// - /// - /// - Task> AddOrUpdate( - string resource, - IEnumerable locales, - string connectionId = null, - CancellationToken cancellationToken = default - ); - - /// - /// Get Specified Locale ... - /// - /// - /// - /// - /// - Task GetLocale( - string suffix, - string language = null, - CancellationToken cancellationToken = default - ); - - /// - /// Add Specified Resource ... - /// - /// - /// - /// - /// - /// - Task AddResource( - string suffix, - XResourceDto item, - string connectionId = null, - CancellationToken cancellationToken = default - ); - - /// - /// Get Resources of Specified Resource ... - /// - /// - /// - /// - Task GetResource( - string suffix, - CancellationToken cancellationToken = default - ); - - /// - /// Remove Specified Suffix Resources ... - /// - /// - /// - /// - /// - Task Remove( - string suffix, - string connectionId = null, - CancellationToken cancellationToken = default - ); - - /// - /// Remove Specified Resource ... - /// - /// - /// - /// - /// - /// - Task Remove( - string resource, - string language, - string connectionId = null, - CancellationToken cancellationToken = default - ); - #endregion - } -} \ No newline at end of file diff --git a/Interfaces/IXBaseStringResourceProviderControllerBase.cs b/Interfaces/IXBaseStringResourceProviderControllerBase.cs deleted file mode 100644 index b8ab67f..0000000 --- a/Interfaces/IXBaseStringResourceProviderControllerBase.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using xModels.Base; -using xModels.Dtos; -using xStringService.Models.Dtos; - -namespace xStringService.Interfaces -{ - /// - /// an Interface which Described Base Actions of a Controller which Provides - /// XString Resource Service Actions ... - /// - public interface IXBaseStringResourceProviderControllerBase - { - /// - /// Add Specified Locales ... - /// - /// - /// - /// - /// - [HttpPost("Add")] - Task>> Add( - [FromQuery] string suffix, - [FromBody] XBaseRangeRequest locales, - CancellationToken cancellationToken = default - ); - - /// - /// Add or Update Specified Locales ... - /// - /// - /// - /// - /// - [HttpPost("AddOrUpdate")] - Task>> AddOrUpdate( - [FromQuery] string resource, - [FromBody] XBaseRangeRequest locales, - CancellationToken cancellationToken = default - ); - - /// - /// Add Specified Resource ... - /// - /// - /// - /// - /// - [HttpPost("AddResource")] - Task> AddResource( - [FromQuery] string suffix, - [FromBody] XResourceDto item, - CancellationToken cancellationToken = default - ); - - /// - /// Get Specified Locale ... - /// - /// - /// - /// - /// - [HttpGet("GetLocale")] - Task> GetLocale( - [FromQuery] string suffix, - [FromQuery] string language = null, - CancellationToken cancellationToken = default - ); - - /// - /// Get Resources of Specified Resource Title ... - /// - /// - /// - /// - [HttpGet("GetResource")] - Task> GetResource( - [FromQuery] string suffix, - CancellationToken cancellationToken = default - ); - - /// - /// Remove all Resources which belongs to Specified Suffix ... - /// - /// - /// - /// - [HttpDelete("Remove")] - Task Remove( - [FromQuery] string suffix, - CancellationToken cancellationToken = default - ); - - /// - /// Remove Specified Resource ... - /// - /// - /// - /// - /// - [HttpDelete("RemoveResource")] - Task Remove( - [FromQuery] string resource, - [FromQuery] string language, - CancellationToken cancellationToken = default - ); - } -} \ No newline at end of file diff --git a/Interfaces/IXItemResourceProvider.cs b/Interfaces/IXItemResourceProvider.cs new file mode 100644 index 0000000..05217eb --- /dev/null +++ b/Interfaces/IXItemResourceProvider.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using xStringService.Models.Dtos; + +namespace xStringService.Interfaces +{ + public interface IXItemResourceProvider + { + // + #region All Item Actions ... + /// + /// Retrieve a List of Exists Languages for Current Item ... + /// + /// + /// + Task> GetLanguages( + CancellationToken cancellationToken = default + ); + + /// + /// Retrieve all Exists Items of type ... + /// + /// + /// + Task> GetResourceLocales( + CancellationToken cancellationToken = default + ); + #endregion + + // + #region Single Item Actions ... + /// + /// Retrieve a List of Exists Languages for Current Item ... + /// + /// + /// + /// + Task> GetLanguages( + object identifier, + CancellationToken cancellationToken = default + ); + + /// + /// Retrieve all Exists Items of type ... + /// + /// + /// + /// + Task> GetResourceLocales( + object identifier, + CancellationToken cancellationToken = default + ); + #endregion + } +} \ No newline at end of file diff --git a/Providers/XBaseItemResourceProvider.cs b/Providers/XBaseItemResourceProvider.cs new file mode 100644 index 0000000..94211ab --- /dev/null +++ b/Providers/XBaseItemResourceProvider.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using xCommons.Extensions; +using xExceptions.Constants; +using xStringService.Interfaces; +using xStringService.Interfaces.Dtos; +using xStringService.Models.Dtos; + +namespace xStringService.Providers +{ + public abstract class XBaseItemResourceProvider : IXItemResourceProvider + { + /// + /// Item Name for Resource Providing ... + /// + private readonly string item; + + /// + /// an Implementation of Item Resource Provider + /// + /// + private readonly XBaseResourceProvider provider; + + /// + /// String Provider Service ... + /// + private readonly IXStringServiceProvider stringProvider; + + // + #region Constructor ... + protected XBaseItemResourceProvider( + string item, + IXStringServiceProvider stringProvider + ) + { + // + this.item = item; + this.stringProvider = stringProvider; + provider = new XBaseResourceProvider( + item, + stringProvider + ); + } + #endregion + + // + #region All Item Actions ... + /// + /// Retrieve a List of Exists Languages for Current Item ... + /// + /// + /// + public async Task> GetLanguages( + CancellationToken cancellationToken = default + ) + { + // + var result = + (await GetResourceLocales(cancellationToken)) + .Select(x => x.Language) + .Distinct() + .ToList(); + + // + return result; + } + + /// + /// Retrieve all Exists Items of type ... + /// + /// + /// + public async Task> 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) + ); + + // + return result; + } + #endregion + + // + #region Single Item Actions ... + /// + /// Retrieve a List of Exists Languages for Current Item ... + /// + /// + /// + /// + public async Task> GetLanguages( + object identifier, + CancellationToken cancellationToken = default + ) + { + // + // Validate ... + var isValid = !identifier.IsNull(); + if (!isValid) + { + XException.InvalidArgs.Throw(); + } + + // + // Set Identifier ... + SetResourceTitle(identifier); + + // + var result = + await provider.GetLanguages(cancellationToken); + return result; + } + + /// + /// Retrieve all Exists Items of type ... + /// + /// + /// + /// + public async Task> GetResourceLocales( + object identifier, + CancellationToken cancellationToken = default + ) + { + // + // Validate ... + var isValid = !identifier.IsNull(); + if (!isValid) + { + XException.InvalidArgs.Throw(); + } + + // + // Set Identifier ... + SetResourceTitle(identifier); + + // + var result = + await provider.GetResourceLocales(cancellationToken); + return result; + } + #endregion + + // + #region Private ... + private string GetResourceTitle(object identifier = null) + { + // + var result = item; + + // + if (!identifier.IsNull()) + { + result = $"{item}_{identifier}"; + } + + // + return result; + } + + private void SetResourceTitle(object identifier = null) + { + // + var itemIdentifier = GetResourceTitle(identifier); + provider.SetField( + field: "resource", + value: $"{itemIdentifier}" + ); + } + #endregion + } +} \ No newline at end of file diff --git a/Providers/XBaseResourceProvider.cs b/Providers/XBaseResourceProvider.cs index 3c5dbd5..23303ff 100644 --- a/Providers/XBaseResourceProvider.cs +++ b/Providers/XBaseResourceProvider.cs @@ -14,12 +14,12 @@ using xStringService.Models.Dtos; namespace xStringService.Providers { - public abstract class XBaseResourceProvider : IXResourceProvider + public class XBaseResourceProvider : IXResourceProvider { protected string resource; private readonly IXStringServiceProvider provider; - protected XBaseResourceProvider( + public XBaseResourceProvider( string resource, IXStringServiceProvider provider ) @@ -364,7 +364,7 @@ namespace xStringService.Providers #endregion // - #region Provate ... + #region Private ... private async Task> ExtractItems( CancellationToken cancellationToken = default ) @@ -384,11 +384,6 @@ namespace xStringService.Providers // return result; } - - // public void SetResourceTitle(string resource) - // { - // this.resource = resource; - // } #endregion } } \ No newline at end of file diff --git a/Providers/XBaseStringResourceProvider.cs b/Providers/XBaseStringResourceProvider.cs deleted file mode 100644 index a0cdba3..0000000 --- a/Providers/XBaseStringResourceProvider.cs +++ /dev/null @@ -1,405 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using xCommons.Configurations; -using xCommons.Extensions; -using xExceptions.Constants; -using xModels.Dtos; -using xStringService.Extensions; -using xStringService.Interfaces; -using xStringService.Interfaces.Dtos; -using xStringService.Models.Dtos; - -namespace xStringService.Providers -{ - /// - /// a Base Class for Handling Resources Based on Specified Types on - /// String Resources Use ... - /// such as: - /// - Terms and Conditions; - /// - Contents; - /// - News; - /// - etc ... - /// - public abstract class XBaseStringResourceProvider : IXBaseStringResourceProvider - { - // - #region Props ... - public string Prefix { get; } - public IXStringServiceProvider Provider { get; } - public XAppConfiguration AppConfiguration { get; } - #endregion - - // - #region Constructor ... - public XBaseStringResourceProvider( - string prefix, - IXStringServiceProvider provider, - XAppConfiguration appConfiguration - ) - { - // - Prefix = prefix; - Provider = provider; - AppConfiguration = appConfiguration; - } - #endregion - - // - #region Actions ... - /// - /// Prepare Resource Title by Given Data ... - /// - /// - /// - public string GetResourceTitle(string suffix) - { - // - string result = ""; - - // - if (suffix.IsNullOrEmpty()) - { - return result; - } - - // - result = $"{Prefix}_${suffix}"; - - // - return result; - } - - /// - /// Add Specified Locales ... - /// - /// - /// - /// - /// - /// - public async Task> Add( - string suffix, - IEnumerable locales, - string connectionId = null, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - var has = - locales.HasChild() && - !suffix.IsNullOrEmpty(); - if (!has) - { - XException.InvalidArgs.Throw(); - } - - // - // Prepare Resource ID ... - string resourceID = GetResourceTitle(suffix); - var result = await locales.SelectAsync(async l => - { - // - // Normalize Language ... - if (l.Language.IsNullOrEmpty()) - { - l.Language = AppConfiguration.DefaultLanguage; - } - - // - // Prepare Model for Add ... - var model = new XStringDto - { - Language = l.Language, - TranslatedValue = l.Value, - ResourceTitle = resourceID, - }; - model = await Provider.AddAsync( - item: model, - saveChanges: true, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - return model; - }); - - // - return result; - } - - /// - /// Add Or Update Specified Locals ... - /// - /// - /// - /// - /// - /// - public async Task> AddOrUpdate( - string resource, - IEnumerable locales, - string connectionId = null, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - bool isValid = - locales.HasChild() && - !resource.IsNullOrEmpty() && - locales.All(l => !l.Value.IsNullOrEmpty() && !l.Language.IsNullOrEmpty()); - if (!isValid) - { - XException.InvalidArgs.Throw(); - } - - // - // Check Resource ... - isValid = resource.Contains(Prefix); - if (!isValid) - { - XException.NotAllowed.Throw(); - } - - // - var result = await locales.SelectAsync(async l => - await Provider.AddOrUpdateByLocaleResource( - item: l, - resource: resource, - connectionId: connectionId, - cancellationToken: cancellationToken - ) - ); - - // - return result; - } - - /// - /// Get Specified Locale ... - /// - /// - /// - /// - /// - public async Task GetLocale( - string suffix, - string language = null, - CancellationToken cancellationToken = default - ) - { - // - // Normalize ... - if (language.IsNullOrEmpty()) - { - language = AppConfiguration.DefaultLanguage; - } - - // - // Validate ... - if (suffix.IsNullOrEmpty() || language.IsNullOrEmpty()) - { - XException.InvalidArgs.Throw(); - } - - // - // Prepare Resource Title ... - string resource = GetResourceTitle(suffix); - - // - // Check Resource Exists ... - var isExists = await Provider.IsResourceExists( - resource: resource, - language: language, - cancellationToken: cancellationToken - ); - if (!isExists) - { - XException.NotFound.Throw(); - } - - // - // Retrieve and Validate Dto Model ... - var model = await Provider.Get( - resource: resource, - language: language, - cancellationToken: cancellationToken - ); - if (model.IsNullOrDefault()) - { - XException.ActionFailed.Throw(); - } - - // - // Prepare Result ... - var result = model - .ToXLocaleResourceDto(); - return result; - } - - /// - /// Add Specified Resource ... - /// - /// - /// - /// - /// - /// - public async Task AddResource( - string suffix, - XResourceDto item, - string connectionId = null, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - if (suffix.IsNullOrEmpty() || - item.IsNull() || - !item.Locales.HasChild() || - !item.Locales.All(l => !l.Value.IsNullOrEmpty())) - { - XException.InvalidArgs.Throw(); - } - - // - // Prepare Resource ID ... - var addedLocals = await Add( - suffix: suffix, - locales: item.Locales, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - if (!addedLocals.HasChild()) - { - XException.ActionFailed.Throw(); - } - - // - var result = await GetResource( - suffix: suffix, - cancellationToken: cancellationToken - ); - return result; - } - - /// - /// Get Resources of Specified Resource ... - /// - /// - /// - /// - public async Task GetResource( - string suffix, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - if (suffix.IsNullOrEmpty()) - { - XException.InvalidArgs.Throw(); - } - - // - // Prepare Resource ID ... - string resourceID = GetResourceTitle(suffix); - - // - // Prepare ... - var result = await Provider.GetResource( - resource: resourceID, - cancellationToken: cancellationToken - ); - return result; - } - - /// - /// Remove Specified Suffix Resources ... - /// - /// - /// - /// - /// - public async Task Remove( - string suffix, - string connectionId = null, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - if (suffix.IsNullOrEmpty()) - { - XException.InvalidArgs.Throw(); - } - - // - var resourceID = GetResourceTitle(suffix); - await Provider.RemoveResource( - resource: resourceID, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - } - - /// - /// Remove Specified Resource ... - /// - /// - /// - /// - /// - /// - public async Task Remove( - string resource, - string language, - string connectionId = null, - CancellationToken cancellationToken = default - ) - { - // - // Validate ... - bool isValid = - !resource.IsNullOrEmpty() && - !language.IsNullOrEmpty(); - if (!isValid) - { - XException.InvalidArgs.Throw(); - } - - // - // Check resource ID Contains Prefix ... - isValid = resource.Contains(Prefix); - if (!isValid) - { - XException.NotAllowed.Throw(); - } - - // - // Check Exists ... - var isExists = await Provider.IsResourceExists( - resource: resource, - language: language, - cancellationToken: cancellationToken - ); - if (!isExists) - { - XException.NotFound.Throw(); - } - - // - // Remove Resource ... - await Provider.Remove( - resource: resource, - language: language, - connectionId: connectionId, - cancellationToken: cancellationToken - ); - } - #endregion - } -} \ No newline at end of file