apply sorting ...

This commit is contained in:
2026-09-06 00:18:57 +03:30
parent 5739b968aa
commit 5d9cd2afbe
28 changed files with 159 additions and 68 deletions
@@ -1,10 +1,14 @@
using System;
using System.Linq;
using System.Threading;
using xCommons.Providers;
using xTagService.Interfaces;
using xCommons.Extensions;
using xExceptions.Constants;
using System.Threading.Tasks;
using xCommons.Configurations;
using xPushService.Interfaces;
using xTagService.Controllers;
using Microsoft.AspNetCore.Mvc;
using xContentService.Interfaces;
using xContentService.Models.Dtos;
using xIdentityService.Interfaces;
using Microsoft.Extensions.Logging;
@@ -15,15 +19,17 @@ using xContentService.Interfaces.Controllers;
namespace xContentService.Controllers
{
public abstract class XControllerProviderControllerBase : XBaseProvidedHasTagControllerBase<XContent, XContentDto, Guid, XContentDtoHub>, IXContentProviderController
public abstract class XContentProviderControllerBase : XBaseProvidedHasTagControllerBase<XContent, XContentDto, Guid, XContentDtoHub>, IXContentProviderController
{
protected XControllerProviderControllerBase(
private readonly IXContentProvider provider;
protected XContentProviderControllerBase(
ILogger<XBaseProvidedHasTagControllerBase<XContent, XContentDto, Guid, XContentDtoHub>> logger,
XAppConfiguration appConfiguration,
IXIdentityProvider identityProvider,
XValidationProvider validationProvider,
IXBaseProvided<XContent, XContentDto, Guid, XContentDtoHub> provider,
IXTagProvided<XContent, XContentDto, Guid, XContentDtoHub> tagProvided,
IXContentProvider provider,
IXContentTagProvided tagProvided,
Func<IQueryable<XContent>, IOrderedQueryable<XContent>> defaultOrderBuilder = null,
Func<IQueryable<XContent>, IIncludableQueryable<XContent, object>> defaultIncludeBuilder = null
) : base(
@@ -36,6 +42,72 @@ namespace xContentService.Controllers
defaultOrderBuilder,
defaultIncludeBuilder
)
{ }
{
this.provider = provider;
}
/// <summary>
/// Add an item ...
/// </summary>
/// <param name="item"></param>
/// <param name="language"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost("Add")]
public async Task<ActionResult<XContentDto>> Add(
[FromBody] XContentDto item,
[FromQuery] string language = null,
CancellationToken cancellationToken = default
)
{
//
try
{
//
// Validate ...
if (!ModelState.IsValid)
{
XException.InvalidArgs.Throw();
}
await ValidationProvider
.GroupValidationBuilder()
.AddNotNull(item)
.AddNotEmpty(item.Title)
.ValidateGroupAsync();
//
var userInfo = await GetUserInfo();
var connectionId = GetConnectionId();
//
// Normalize Language ...
if (language.IsNullOrEmpty())
{
language = AppConfiguration.DefaultLanguage;
}
if (language.IsNullOrEmpty())
{
XException.InvalidData.Throw();
}
//
var result = await provider.Add(
item: item,
userInfo: userInfo,
language: language,
connectionId: connectionId,
cancellationToken: cancellationToken
);
//
return result;
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
}
}