add support for xCategorySubCategoryReferenceProvider in XCategory Provider ...
This commit is contained in:
@@ -19,6 +19,7 @@ using xDataService.Extensions;
|
||||
using xPushService.Constants;
|
||||
using xPushService.Providers;
|
||||
using xDataService.Configuration;
|
||||
using xDataService.Models;
|
||||
|
||||
namespace xCategoryService.Providers
|
||||
{
|
||||
@@ -29,13 +30,15 @@ namespace xCategoryService.Providers
|
||||
private readonly XDataServiceConfiguration dataServiceConfiguration;
|
||||
private readonly IXCategoryTitleResourceProvider titleResourceProvider;
|
||||
private readonly IXCategoryDescriptionResourceProvider descriptionResourceProvider;
|
||||
private readonly IXCategorySubCategoryReferenceProvider categorySubCategoryReferenceProvider;
|
||||
|
||||
public XCategoryProvider(
|
||||
XAppConfiguration appConfiguration,
|
||||
IXCategoryServiceProvider provider,
|
||||
XDataServiceConfiguration dataServiceConfiguration,
|
||||
IXCategoryTitleResourceProvider titleResourceProvider,
|
||||
IXCategoryDescriptionResourceProvider descriptionResourceProvider
|
||||
IXCategoryDescriptionResourceProvider descriptionResourceProvider,
|
||||
IXCategorySubCategoryReferenceProvider categorySubCategoryReferenceProvider
|
||||
) : base(
|
||||
provider,
|
||||
permittedRoles: new string[] { }
|
||||
@@ -47,6 +50,7 @@ namespace xCategoryService.Providers
|
||||
this.titleResourceProvider = titleResourceProvider;
|
||||
this.dataServiceConfiguration = dataServiceConfiguration;
|
||||
this.descriptionResourceProvider = descriptionResourceProvider;
|
||||
this.categorySubCategoryReferenceProvider = categorySubCategoryReferenceProvider;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -849,7 +853,7 @@ namespace xCategoryService.Providers
|
||||
//
|
||||
// Descriptions ...
|
||||
var updateDescriptions = result.Descriptions.Locales.Where(
|
||||
l => resource.Descriptions.Locales.Any(r =>
|
||||
l => resource.Descriptions.Locales.Any(r =>
|
||||
r.Value
|
||||
.Equals(l.Value, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
r.Language
|
||||
@@ -1179,5 +1183,261 @@ namespace xCategoryService.Providers
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region SubCategory References ...
|
||||
/// <summary>
|
||||
/// Get Specified Indexed Reference for Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="forIndex"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XCategoryDto> GetReference(
|
||||
int providedForId,
|
||||
int forIndex = 0,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.GetReference(
|
||||
forIndex: forIndex,
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists References of Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XCategoryDto>> GetAllReferences(
|
||||
int providedForId,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.GetAllReferences(
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract all Referencing Models for Specified Key ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XReference<int>>> GetAllReferencings(
|
||||
int providedForId,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.GetAllReferencings(
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count References ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> CountReferences(
|
||||
int providedForId,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.CountReferences(
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve References of Specific Provided ID as Query ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XCategoryDto>> QueryReferences(
|
||||
XQuery query,
|
||||
int providedForId,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.QueryReferences(
|
||||
query: query,
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Reference a Model to Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddReference(
|
||||
XCategoryDto model,
|
||||
int providedForId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.AddReference(
|
||||
model: model,
|
||||
connectionId: connectionId,
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Reference a Model to Specific XRefence<TKey/> ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="reference"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddReference(
|
||||
XCategoryDto model,
|
||||
XReference<int> reference,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.AddReference(
|
||||
model: model,
|
||||
reference: reference,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Reference a Model for Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveReference(
|
||||
XCategoryDto model,
|
||||
int providedForId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.RemoveReference(
|
||||
model: model,
|
||||
connectionId: connectionId,
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Reference a Model for Specific XRefence<TKey/> ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="reference"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveReference(
|
||||
XCategoryDto model,
|
||||
XReference<int> reference,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.RemoveReference(
|
||||
model: model,
|
||||
reference: reference,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove All References to Specified Key ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveReferences(
|
||||
int providedForId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await categorySubCategoryReferenceProvider
|
||||
.RemoveReferences(
|
||||
connectionId: connectionId,
|
||||
providedForId: providedForId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user