Add XBaseResourceProvider Class and Interfaces for Handle String Resource Based Services Implementation ...
This commit is contained in:
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
@@ -126,6 +125,58 @@ namespace xStringService.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XStringDto> Get(
|
||||
string resource,
|
||||
string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
if (language.IsNullOrEmpty())
|
||||
{
|
||||
language = AppConfiguration.DefaultLanguage;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
if (resource.IsNullOrEmpty() || language.IsNullOrEmpty())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resource Exists ...
|
||||
var isExists = await IsResourceExists(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
if (!isExists)
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var entity = await Repository
|
||||
.FindOneAsync(e =>
|
||||
e.ResourceTitle == resource &&
|
||||
e.Language.ToNormalString() == language.ToNormalString()
|
||||
);
|
||||
if (entity.IsNullOrDefault())
|
||||
{
|
||||
XException.ActionFailed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
return entity
|
||||
.ToDynamicObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Translation of Specified Resource ...
|
||||
/// </summary>
|
||||
@@ -417,19 +468,19 @@ namespace xStringService.Providers
|
||||
if (totalItemsCount > 0 &&
|
||||
filteredItemsCount > 0)
|
||||
{
|
||||
//
|
||||
// Apply Paging ...
|
||||
items = items.ApplyPaging(
|
||||
query.Page,
|
||||
query.PageSize
|
||||
);
|
||||
|
||||
//
|
||||
// Apply Sorting ...
|
||||
items = items.ApplySorting(
|
||||
query.SortBy,
|
||||
query.IsAscending
|
||||
);
|
||||
|
||||
//
|
||||
// Apply Paging ...
|
||||
items = items.ApplyPaging(
|
||||
query.Page,
|
||||
query.PageSize
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user