Complete Category and SubCategory Base Actions, and also ControllersBase and their Implemented Usages ...
This commit is contained in:
@@ -0,0 +1,470 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCategoryService.Interfaces;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Controllers;
|
||||
|
||||
namespace xCategoryService.Controllers
|
||||
{
|
||||
public abstract class XCategoryProviderControllerBase : XBaseProvidedController<XCategory, XCategoryDto, int, XCategoryDtoHub>, IXCategoryProviderController
|
||||
{
|
||||
private readonly IXCategoryProvider provider;
|
||||
|
||||
protected XCategoryProviderControllerBase(
|
||||
ILogger<XCategoryProviderControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXCategoryProvider provider,
|
||||
Func<IQueryable<XCategory>, IOrderedQueryable<XCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XCategory>, IIncludableQueryable<XCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
provider,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Check Has Specified Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}/HasLocale")]
|
||||
public virtual async Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] int id,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
ValidationProvider.NotEmpty(language);
|
||||
|
||||
//
|
||||
var result = await provider.HasLocale(
|
||||
id: id,
|
||||
language: language,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an Item by all of it's Related Translations ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}")]
|
||||
public virtual async Task<ActionResult<XCategoryResourceDto>> GetResource(
|
||||
[FromRoute] int id,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = await provider.GetResource(
|
||||
id: id,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources")]
|
||||
public virtual async Task<ActionResult<XCategoryResourceDto>> Add(
|
||||
[FromBody] XCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(item)
|
||||
.AddNotEmpty(language)
|
||||
.AddNotEmpty(item.Title)
|
||||
.AddNotEmpty(item.Description)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Add(
|
||||
item: item,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Resources/{id}")]
|
||||
public virtual async Task<ActionResult<XCategoryResourceDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(item)
|
||||
.AddNotEmpty(language)
|
||||
.AddNotEmpty(item.Title)
|
||||
.AddNotEmpty(item.Description)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Update(
|
||||
id: id,
|
||||
item: item,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources/Refresh")]
|
||||
public virtual async Task<ActionResult<XCategoryResourceDto>> Refresh(
|
||||
[FromBody] XCategoryResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(resource)
|
||||
.AddNotNull(resource.Item)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Refresh(
|
||||
resource: resource,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Resources ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/All")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XCategoryResourceDto>>> GetAllResources(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = await provider.GetAllResources(
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find One Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/One")]
|
||||
public virtual async Task<ActionResult<XCategoryResourceDto>> FindOneResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.FindOneResource(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x => x.PropValuesContains(query)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/Many")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XCategoryResourceDto>>> FindManyResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.FindManyResource(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x => x.PropValuesContains(query),
|
||||
orderBuilder: x => x.OrderBy(y => y.Item.Id)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Resources by Query Pattern ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Query")]
|
||||
public virtual async Task<ActionResult<XQueryResult<XCategoryResourceDto>>> QueryResources(
|
||||
[FromQuery] XQuery query = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.QueryResources(
|
||||
query: query,
|
||||
predicate: null,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.Item.Id)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCategoryService.Interfaces;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Controllers;
|
||||
|
||||
namespace xCategoryService.Controllers
|
||||
{
|
||||
public abstract class XSubCategoryProviderControllerBase : XBaseProvidedController<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>, IXSubCategoryProviderController
|
||||
{
|
||||
private readonly IXSubCategoryProvider provider;
|
||||
|
||||
protected XSubCategoryProviderControllerBase(
|
||||
ILogger<XSubCategoryProviderControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXSubCategoryProvider provider,
|
||||
Func<IQueryable<XSubCategory>, IOrderedQueryable<XSubCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XSubCategory>, IIncludableQueryable<XSubCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
provider,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Check Has Specified Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}/HasLocale")]
|
||||
public virtual async Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] int id,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
ValidationProvider.NotEmpty(language);
|
||||
|
||||
//
|
||||
var result = await provider.HasLocale(
|
||||
id: id,
|
||||
language: language,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an Item by all of it's Related Translations ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}")]
|
||||
public virtual async Task<ActionResult<XSubCategoryResourceDto>> GetResource(
|
||||
[FromRoute] int id,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = await provider.GetResource(
|
||||
id: id,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources")]
|
||||
public virtual async Task<ActionResult<XSubCategoryResourceDto>> Add(
|
||||
[FromBody] XSubCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(item)
|
||||
.AddNotEmpty(language)
|
||||
.AddNotEmpty(item.Title)
|
||||
.AddNotEmpty(item.Description)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Add(
|
||||
item: item,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Resources/{id}")]
|
||||
public virtual async Task<ActionResult<XSubCategoryResourceDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XSubCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid ||
|
||||
!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(item)
|
||||
.AddNotEmpty(language)
|
||||
.AddNotEmpty(item.Title)
|
||||
.AddNotEmpty(item.Description)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Update(
|
||||
id: id,
|
||||
item: item,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources/Refresh")]
|
||||
public virtual async Task<ActionResult<XSubCategoryResourceDto>> Refresh(
|
||||
[FromBody] XSubCategoryResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(resource)
|
||||
.AddNotNull(resource.Item)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
// Reading Requirements ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await provider.Refresh(
|
||||
resource: resource,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Resources ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/All")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XSubCategoryResourceDto>>> GetAllResources(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = await provider.GetAllResources(
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find One Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/One")]
|
||||
public virtual async Task<ActionResult<XSubCategoryResourceDto>> FindOneResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.FindOneResource(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x => x.PropValuesContains(query)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/Many")]
|
||||
public virtual async Task<ActionResult<IEnumerable<XSubCategoryResourceDto>>> FindManyResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.FindManyResource(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x => x.PropValuesContains(query),
|
||||
orderBuilder: x => x.OrderBy(y => y.Item.Id)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Resources by Query Pattern ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Query")]
|
||||
public virtual async Task<ActionResult<XQueryResult<XSubCategoryResourceDto>>> QueryResources(
|
||||
[FromQuery] XQuery query = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(query)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await provider.QueryResources(
|
||||
query: query,
|
||||
predicate: null,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.Item.Id)
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+31
-19
@@ -283,30 +283,42 @@ namespace xCategoryService.DI
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXCategoryDescriptionResourceProvider), typeof(XCategoryDescriptionResourceProvider), lifeTime)
|
||||
);
|
||||
|
||||
//
|
||||
// Provider ...
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXCategoryProvider), typeof(XCategoryProvider), lifeTime)
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region SubCategory ...
|
||||
// //
|
||||
// // Models ...
|
||||
// services.Add(
|
||||
// new ServiceDescriptor(typeof(IXSubCategoryServiceProvider), typeof(XSubCategoryServiceProvider), lifeTime)
|
||||
// );
|
||||
// services.Add(
|
||||
// new ServiceDescriptor(typeof(IXSubCategoryRepositoryService), typeof(XSubCategoryRepositoryService), lifeTime)
|
||||
// );
|
||||
// services.Add(
|
||||
// new ServiceDescriptor(typeof(IXSubCategoryRepositoryProvider), typeof(XSubCategoryRepositoryProvider), lifeTime)
|
||||
// );
|
||||
//
|
||||
// Models ...
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryServiceProvider), typeof(XSubCategoryServiceProvider), lifeTime)
|
||||
);
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryRepositoryService), typeof(XSubCategoryRepositoryService), lifeTime)
|
||||
);
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryRepositoryProvider), typeof(XSubCategoryRepositoryProvider), lifeTime)
|
||||
);
|
||||
|
||||
// //
|
||||
// // Resource Providers ...
|
||||
// services.Add(
|
||||
// new ServiceDescriptor(typeof(IXSubCategoryTitleResourceProvider), typeof(XSubCategoryTitleResourceProvider), lifeTime)
|
||||
// );
|
||||
// services.Add(
|
||||
// new ServiceDescriptor(typeof(IXSubCategoryDescriptionResourceProvider), typeof(XSubCategoryDescriptionResourceProvider), lifeTime)
|
||||
// );
|
||||
//
|
||||
// Resource Providers ...
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryTitleResourceProvider), typeof(XSubCategoryTitleResourceProvider), lifeTime)
|
||||
);
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryDescriptionResourceProvider), typeof(XSubCategoryDescriptionResourceProvider), lifeTime)
|
||||
);
|
||||
|
||||
//
|
||||
// Provider ...
|
||||
services.Add(
|
||||
new ServiceDescriptor(typeof(IXSubCategoryProvider), typeof(XSubCategoryProvider), lifeTime)
|
||||
);
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xCommons.Extensions;
|
||||
|
||||
@@ -9,36 +10,6 @@ namespace xCategoryService.Extensions
|
||||
/// </summary>
|
||||
public static class XCategoryResourceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Check a Resource is Valid or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(
|
||||
this XCategoryResourceDto source
|
||||
)
|
||||
{
|
||||
//
|
||||
return
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Item.IsNullOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a Resource is a New Resource for Add or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsNew(
|
||||
this XCategoryResourceDto source
|
||||
)
|
||||
{
|
||||
//
|
||||
return
|
||||
source.IsValid() &&
|
||||
!source.Item.Id.IsValidIntId();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract Available Languages ...
|
||||
/// </summary>
|
||||
@@ -53,7 +24,7 @@ namespace xCategoryService.Extensions
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
if (!source.IsValid())
|
||||
if (!source.IsNullOrDefault())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -69,11 +40,82 @@ namespace xCategoryService.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
// public static bool ValidateResources(
|
||||
// this XCategoryResourceDto source
|
||||
// )
|
||||
// {
|
||||
// var result =
|
||||
// }
|
||||
/// <summary>
|
||||
/// Check Has Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasLocale(
|
||||
this XCategoryResourceDto source,
|
||||
string language
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!language.IsNullOrEmpty() &&
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Titles.Locales
|
||||
.Any(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Item Translation ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public static XCategoryDto GetTranslate(
|
||||
this XCategoryResourceDto source,
|
||||
string language
|
||||
)
|
||||
{
|
||||
//
|
||||
XCategoryDto result = null;
|
||||
|
||||
//
|
||||
var isValid = source
|
||||
.HasLocale(language);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
var titleLocale = source.Titles.Locales
|
||||
.FirstOrDefault(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
var descriptionLocale = source.Descriptions.Locales
|
||||
.FirstOrDefault(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
isValid = !titleLocale.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = source.Item;
|
||||
result.Title = titleLocale.Value;
|
||||
result.Description =
|
||||
descriptionLocale.IsNullOrDefault()
|
||||
? string.Empty
|
||||
: descriptionLocale.Value;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using System.Linq;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xCategoryService.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions Method Related to XSubCategoryResourceDto ...
|
||||
/// </summary>
|
||||
public static class XSubCategoryResourceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extract Available Languages ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] ExtractLanguages(
|
||||
this XSubCategoryResourceDto source
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = new string[] { };
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
if (!source.IsNullOrDefault())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
source.Titles.Locales.Select(x => x.Language)
|
||||
.Union(source.Descriptions.Locales.Select(x => x.Language))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Has Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasLocale(
|
||||
this XSubCategoryResourceDto source,
|
||||
string language
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!language.IsNullOrEmpty() &&
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Titles.Locales
|
||||
.Any(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Item Translation ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public static XSubCategoryDto GetTranslate(
|
||||
this XSubCategoryResourceDto source,
|
||||
string language
|
||||
)
|
||||
{
|
||||
//
|
||||
XSubCategoryDto result = null;
|
||||
|
||||
//
|
||||
var isValid = source
|
||||
.HasLocale(language);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
var titleLocale = source.Titles.Locales
|
||||
.FirstOrDefault(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
var descriptionLocale = source.Descriptions.Locales
|
||||
.FirstOrDefault(l => l.Language
|
||||
.Equals(
|
||||
language,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
isValid = !titleLocale.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = source.Item;
|
||||
result.Title = titleLocale.Value;
|
||||
result.Description =
|
||||
descriptionLocale.IsNullOrDefault()
|
||||
? string.Empty
|
||||
: descriptionLocale.Value;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,14 +43,14 @@ namespace xCategoryService.Interfaces
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="langauge"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XCategoryResourceDto> Add(
|
||||
XCategoryDto item,
|
||||
string langauge = null,
|
||||
string language = null,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -76,14 +76,14 @@ namespace xCategoryService.Interfaces
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Referesh a Resource ...
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XCategoryResourceDto> Referesh(
|
||||
Task<XCategoryResourceDto> Refresh(
|
||||
XCategoryResourceDto resource,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
@@ -105,7 +105,7 @@ namespace xCategoryService.Interfaces
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XCategoryResourceDto> FindOne(
|
||||
Task<XCategoryResourceDto> FindOneResource(
|
||||
Expression<Func<XCategoryResourceDto, bool>> predicate = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -116,7 +116,7 @@ namespace xCategoryService.Interfaces
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XCategoryResourceDto>> FindMany(
|
||||
Task<IEnumerable<XCategoryResourceDto>> FindManyResource(
|
||||
Expression<Func<XCategoryResourceDto, bool>> predicate = null,
|
||||
Func<IQueryable<XCategoryResourceDto>, IOrderedQueryable<XCategoryResourceDto>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -1,10 +1,129 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces
|
||||
{
|
||||
public interface IXCategoryProviderController : IXBaseProvidedController<XCategory, XCategoryDto, int, XCategoryDtoHub>
|
||||
{ }
|
||||
{
|
||||
/// <summary>
|
||||
/// Check Has Specified Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}/HasLocale")]
|
||||
Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] int id,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Load an Item by all of it's Related Translations ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}")]
|
||||
Task<ActionResult<XCategoryResourceDto>> GetResource(
|
||||
[FromRoute] int id,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources")]
|
||||
Task<ActionResult<XCategoryResourceDto>> Add(
|
||||
[FromBody] XCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Resources/{id}")]
|
||||
Task<ActionResult<XCategoryResourceDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources/Refresh")]
|
||||
Task<ActionResult<XCategoryResourceDto>> Refresh(
|
||||
[FromBody] XCategoryResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get All Resources ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/All")]
|
||||
Task<ActionResult<IEnumerable<XCategoryResourceDto>>> GetAllResources(
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Find One Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/One")]
|
||||
Task<ActionResult<XCategoryResourceDto>> FindOneResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/Many")]
|
||||
Task<ActionResult<IEnumerable<XCategoryResourceDto>>> FindManyResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Resources by Query Pattern ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Query")]
|
||||
Task<ActionResult<XQueryResult<XCategoryResourceDto>>> QueryResources(
|
||||
[FromQuery] XQuery query = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -43,14 +43,14 @@ namespace xCategoryService.Interfaces
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="langauge"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XSubCategoryResourceDto> Add(
|
||||
XSubCategoryDto item,
|
||||
string langauge = null,
|
||||
string language = null,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -76,14 +76,14 @@ namespace xCategoryService.Interfaces
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Referesh a Resource ...
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XSubCategoryResourceDto> Referesh(
|
||||
Task<XSubCategoryResourceDto> Refresh(
|
||||
XSubCategoryResourceDto resource,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
@@ -105,7 +105,7 @@ namespace xCategoryService.Interfaces
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XSubCategoryResourceDto> FindOne(
|
||||
Task<XSubCategoryResourceDto> FindOneResource(
|
||||
Expression<Func<XSubCategoryResourceDto, bool>> predicate = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -116,7 +116,7 @@ namespace xCategoryService.Interfaces
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XSubCategoryResourceDto>> FindMany(
|
||||
Task<IEnumerable<XSubCategoryResourceDto>> FindManyResource(
|
||||
Expression<Func<XSubCategoryResourceDto, bool>> predicate = null,
|
||||
Func<IQueryable<XSubCategoryResourceDto>, IOrderedQueryable<XSubCategoryResourceDto>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -1,10 +1,129 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xCategoryService.Providers.Dtos;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces
|
||||
{
|
||||
public interface IXSubCategoryProviderController : IXBaseProvidedController<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>
|
||||
{ }
|
||||
{
|
||||
/// <summary>
|
||||
/// Check Has Specified Locale or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}/HasLocale")]
|
||||
Task<ActionResult<bool>> HasLocale(
|
||||
[FromRoute] int id,
|
||||
[FromQuery] string language,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Load an Item by all of it's Related Translations ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/{id}")]
|
||||
Task<ActionResult<XSubCategoryResourceDto>> GetResource(
|
||||
[FromRoute] int id,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources")]
|
||||
Task<ActionResult<XSubCategoryResourceDto>> Add(
|
||||
[FromBody] XSubCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a Category Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Resources/{id}")]
|
||||
Task<ActionResult<XSubCategoryResourceDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XSubCategoryDto item,
|
||||
[FromQuery] string language = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Resources/Refresh")]
|
||||
Task<ActionResult<XSubCategoryResourceDto>> Refresh(
|
||||
[FromBody] XSubCategoryResourceDto resource,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get All Resources ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/All")]
|
||||
Task<ActionResult<IEnumerable<XSubCategoryResourceDto>>> GetAllResources(
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Find One Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/One")]
|
||||
Task<ActionResult<XSubCategoryResourceDto>> FindOneResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Resource ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Find/Many")]
|
||||
Task<ActionResult<IEnumerable<XSubCategoryResourceDto>>> FindManyResource(
|
||||
[FromQuery] string query,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Resources by Query Pattern ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Resources/Query")]
|
||||
Task<ActionResult<XQueryResult<XSubCategoryResourceDto>>> QueryResources(
|
||||
[FromQuery] XQuery query = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -154,14 +154,14 @@ namespace xCategoryService.Providers
|
||||
/// Add an Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="langauge"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XCategoryResourceDto> Add(
|
||||
XCategoryDto item,
|
||||
string langauge = null,
|
||||
string language = null,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -169,9 +169,9 @@ namespace xCategoryService.Providers
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
langauge =
|
||||
!langauge.IsNullOrEmpty()
|
||||
? langauge
|
||||
language =
|
||||
!language.IsNullOrEmpty()
|
||||
? language
|
||||
: appConfiguration.DefaultLanguage;
|
||||
|
||||
//
|
||||
@@ -220,7 +220,7 @@ namespace xCategoryService.Providers
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Value = title,
|
||||
Language = langauge
|
||||
Language = language
|
||||
},
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -231,7 +231,7 @@ namespace xCategoryService.Providers
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Value = description,
|
||||
Language = langauge
|
||||
Language = language
|
||||
},
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -415,7 +415,7 @@ namespace xCategoryService.Providers
|
||||
}
|
||||
|
||||
//
|
||||
resource = await Referesh(
|
||||
resource = await Refresh(
|
||||
resource: resource,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
@@ -427,14 +427,14 @@ namespace xCategoryService.Providers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Referesh a Resource ...
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XCategoryResourceDto> Referesh(
|
||||
public async Task<XCategoryResourceDto> Refresh(
|
||||
XCategoryResourceDto resource,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
@@ -792,7 +792,7 @@ namespace xCategoryService.Providers
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XCategoryResourceDto> FindOne(
|
||||
public async Task<XCategoryResourceDto> FindOneResource(
|
||||
Expression<Func<XCategoryResourceDto, bool>> predicate = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -831,7 +831,7 @@ namespace xCategoryService.Providers
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XCategoryResourceDto>> FindMany(
|
||||
public async Task<IEnumerable<XCategoryResourceDto>> FindManyResource(
|
||||
Expression<Func<XCategoryResourceDto, bool>> predicate = null,
|
||||
Func<IQueryable<XCategoryResourceDto>, IOrderedQueryable<XCategoryResourceDto>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -893,7 +893,7 @@ namespace xCategoryService.Providers
|
||||
query = query.NormalizeQuery(dataServiceConfiguration);
|
||||
|
||||
//
|
||||
var items = await FindMany(
|
||||
var items = await FindManyResource(
|
||||
predicate: predicate,
|
||||
orderBuilder: orderBuilder,
|
||||
cancellationToken: cancellationToken
|
||||
|
||||
@@ -153,14 +153,14 @@ namespace xCategoryService.Providers
|
||||
/// Add an Item for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="langauge"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XSubCategoryResourceDto> Add(
|
||||
XSubCategoryDto item,
|
||||
string langauge = null,
|
||||
string language = null,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -168,9 +168,9 @@ namespace xCategoryService.Providers
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
langauge =
|
||||
!langauge.IsNullOrEmpty()
|
||||
? langauge
|
||||
language =
|
||||
!language.IsNullOrEmpty()
|
||||
? language
|
||||
: appConfiguration.DefaultLanguage;
|
||||
|
||||
//
|
||||
@@ -219,7 +219,7 @@ namespace xCategoryService.Providers
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Value = title,
|
||||
Language = langauge
|
||||
Language = language
|
||||
},
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -230,7 +230,7 @@ namespace xCategoryService.Providers
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Value = description,
|
||||
Language = langauge
|
||||
Language = language
|
||||
},
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -414,7 +414,7 @@ namespace xCategoryService.Providers
|
||||
}
|
||||
|
||||
//
|
||||
resource = await Referesh(
|
||||
resource = await Refresh(
|
||||
resource: resource,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
@@ -426,14 +426,14 @@ namespace xCategoryService.Providers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Referesh a Resource ...
|
||||
/// Refresh a Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XSubCategoryResourceDto> Referesh(
|
||||
public async Task<XSubCategoryResourceDto> Refresh(
|
||||
XSubCategoryResourceDto resource,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
@@ -791,7 +791,7 @@ namespace xCategoryService.Providers
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XSubCategoryResourceDto> FindOne(
|
||||
public async Task<XSubCategoryResourceDto> FindOneResource(
|
||||
Expression<Func<XSubCategoryResourceDto, bool>> predicate = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -830,7 +830,7 @@ namespace xCategoryService.Providers
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XSubCategoryResourceDto>> FindMany(
|
||||
public async Task<IEnumerable<XSubCategoryResourceDto>> FindManyResource(
|
||||
Expression<Func<XSubCategoryResourceDto, bool>> predicate = null,
|
||||
Func<IQueryable<XSubCategoryResourceDto>, IOrderedQueryable<XSubCategoryResourceDto>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -892,7 +892,7 @@ namespace xCategoryService.Providers
|
||||
query = query.NormalizeQuery(dataServiceConfiguration);
|
||||
|
||||
//
|
||||
var items = await FindMany(
|
||||
var items = await FindManyResource(
|
||||
predicate: predicate,
|
||||
orderBuilder: orderBuilder,
|
||||
cancellationToken: cancellationToken
|
||||
|
||||
Reference in New Issue
Block a user