Compare commits

..
3 Commits
Author SHA1 Message Date
saherelm 18bd6b462e last ... 2026-09-25 19:47:51 +03:30
saherelm 7802ff9561 last ... 2026-09-06 08:45:26 +03:30
saherelm 5d9cd2afbe apply sorting ... 2026-09-06 00:18:57 +03:30
33 changed files with 194 additions and 279 deletions
@@ -1,9 +1,9 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using xContentService.Constants;
using xContentService.Models.Entities;
using xDataService.Providers;
using xContentService.Constants;
using Microsoft.EntityFrameworkCore;
using xContentService.Models.Entities;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace xContentService.Configuration.Entities
{
@@ -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;
}
}
}
}
+4 -4
View File
@@ -1,12 +1,12 @@
using System;
using GraphQL.Types;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xContentService.Providers.Entities;
using xContentService.Providers.GraphQL;
using xDataService.Db;
using xDataService.Models;
using xDataService.Providers;
using xContentService.Models.Entities;
using xContentService.Providers.GraphQL;
using xContentService.Providers.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Helpers
{
@@ -1,5 +1,8 @@
using System;
using System.Threading;
using xTagService.Interfaces;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using xContentService.Models.Dtos;
using xContentService.Providers.Dtos;
using xContentService.Models.Entities;
@@ -8,6 +11,18 @@ namespace xContentService.Interfaces.Controllers
{
public interface IXContentProviderController : IXBaseProvidedHasTagController<XContent, XContentDto, Guid, XContentDtoHub>
{
/// <summary>
/// Add an item ...
/// </summary>
/// <param name="item"></param>
/// <param name="language"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost("Add")]
Task<ActionResult<XContentDto>> Add(
[FromBody] XContentDto item,
[FromQuery] string language = null,
CancellationToken cancellationToken = default
);
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
using System;
using xPushService.Interfaces;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Dtos
{
+1 -51
View File
@@ -1,60 +1,10 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using xDataService.Interfaces;
using System.Collections.Generic;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Dtos
{
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
{
//
#region Enrichers ...
/// <summary>
/// Enrich Specified Item ...
/// </summary>
/// <param name="source"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<XContentDto> Enrich(
XContent source,
CancellationToken cancellationToken = default
);
/// <summary>
/// Enrich Specified Item ...
/// </summary>
/// <param name="source"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<XContentDto> Enrich(
XContentDto source,
CancellationToken cancellationToken = default
);
/// <summary>
/// Enrich Specified Items ...
/// </summary>
/// <param name="sources"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IEnumerable<XContentDto>> EnrichRange(
IEnumerable<XContent> sources,
CancellationToken cancellationToken = default
);
/// <summary>
/// Enrich Specified Items ...
/// </summary>
/// <param name="sources"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IEnumerable<XContentDto>> EnrichRange(
IEnumerable<XContentDto> sources,
CancellationToken cancellationToken = default
);
#endregion
}
{ }
}
+3 -3
View File
@@ -1,8 +1,8 @@
using System;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xContentService.Providers.Dtos;
using xPushService.Interfaces;
using xContentService.Models.Dtos;
using xContentService.Providers.Dtos;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Dtos
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xPushService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
@@ -1,5 +1,5 @@
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
@@ -1,7 +1,7 @@
using System;
using xPushService.Interfaces;
using xContentService.Models.Entities;
using xContentService.Providers.Entities;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Entities
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xContentService.Models.Entities;
namespace xContentService.Interfaces.Entities
{
+15
View File
@@ -27,5 +27,20 @@ namespace xContentService.Interfaces
string language = null,
CancellationToken cancellationToken = default
);
/// <summary>
/// Create Content Used Locales for Creating Posts ...
/// </summary>
/// <param name="item"></param>
/// <param name="userInfo"></param>
/// <param name="connectionId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
// public Task<XContentDto> Create(
// XContentDto item,
// XUserClaimsInfoDto userInfo = null,
// string connectionId = null,
// CancellationToken cancellationToken = default
// );
}
}
+2
View File
@@ -18,6 +18,8 @@ namespace xContentService.Models.Dtos
public string Description { get; set; }
public virtual XResourceDto DescriptionResource { get; set; }
public string[] Tags { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedAt { get; set; }
}
+2 -2
View File
@@ -1,9 +1,9 @@
using System;
using xPushService.Base;
using xContentService.Models.Dtos;
using Microsoft.Extensions.Logging;
using xContentService.Interfaces.Dtos;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xPushService.Base;
namespace xContentService.Providers.Dtos
{
+1 -152
View File
@@ -1,16 +1,8 @@
using System;
using AutoMapper;
using System.Linq;
using xModels.Dtos;
using System.Threading;
using xCommons.Extensions;
using xDataService.Providers;
using System.Threading.Tasks;
using System.Collections.Generic;
using xContentService.Interfaces;
using xContentService.Models.Dtos;
using xIdentityService.Interfaces;
using xIdentityService.Extensions;
using xContentService.Interfaces.Dtos;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
@@ -19,156 +11,13 @@ namespace xContentService.Providers.Dtos
{
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
{
private readonly IXIdentityProvider identityProvider;
private readonly IXContentTitleResourceProvider titleResourceProvider;
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
public XContentRepositoryService(
IXContentRepository repository,
IXIdentityProvider identityProvider,
IXContentTitleResourceProvider titleResourceProvider,
IXContentDescriptionResourceProvider descriptionResourceProvider,
IEnumerable<Profile> mapperProfiles = null
) : base(
repository,
mapperProfiles
)
{
this.identityProvider = identityProvider;
this.titleResourceProvider = titleResourceProvider;
this.descriptionResourceProvider = descriptionResourceProvider;
}
//
#region Enrichers ...
/// <summary>
/// Enrich Specified Item ...
/// </summary>
/// <param name="source"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<XContentDto> Enrich(
XContent source,
CancellationToken cancellationToken = default
)
{
//
// Mapping Default ...
var result = Mapper.Map<XContentDto>(source);
result = await Enrich(
source: result,
cancellationToken: cancellationToken
);
//
return result;
}
/// <summary>
/// Enrich Specified Item ...
/// </summary>
/// <param name="source"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<XContentDto> Enrich(
XContentDto source,
CancellationToken cancellationToken = default
)
{
//
// Handdle Owner ...
XPersonDto owner = null;
if (!source.OwnerId.IsNullOrEmpty())
{
//
// Try to Retrieve User Info ...
var device = identityProvider.GetDevice();
var userInfo = await identityProvider.GetUserInfo(
device: device,
userSelectByParam: source.OwnerId
);
owner = userInfo.ToXPersonDto();
}
//
// Hanlde Content Title ...
string contentTitle = string.Empty;
XResourceDto titleResource = await titleResourceProvider.GetResource(
identifier: source.Id,
cancellationToken: cancellationToken
);
if (!titleResource.IsNullOrDefault())
{
contentTitle = titleResource.Resource;
}
//
// Hanlde Content Description ...
string contentDescription = string.Empty;
XResourceDto descriptionResource = await descriptionResourceProvider.GetResource(
identifier: source.Id,
cancellationToken: cancellationToken
);
if (!descriptionResource.IsNullOrDefault())
{
contentDescription = descriptionResource.Resource;
}
//
// Attach Extracted Items ...
var result = Mapper.Map<XContentDto>(source, options =>
{
//
options.Items[nameof(source.Owner)] = owner;
options.Items[nameof(source.Title)] = contentTitle;
options.Items[nameof(source.TitleResource)] = titleResource;
options.Items[nameof(source.Description)] = contentDescription;
options.Items[nameof(source.DescriptionResource)] = descriptionResource;
});
//
return result;
}
/// <summary>
/// Enrich Specified Items ...
/// </summary>
/// <param name="sources"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<IEnumerable<XContentDto>> EnrichRange(
IEnumerable<XContent> sources,
CancellationToken cancellationToken = default
)
{
//
var tasks = sources
.Select(x => Enrich(x, cancellationToken));
//
var result = await Task.WhenAll(tasks);
return result;
}
/// <summary>
/// Enrich Specified Items ...
/// </summary>
/// <param name="sources"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<IEnumerable<XContentDto>> EnrichRange(
IEnumerable<XContentDto> sources,
CancellationToken cancellationToken = default
)
{
//
var tasks = sources
.Select(x => Enrich(x, cancellationToken));
//
var result = await Task.WhenAll(tasks);
return result;
}
#endregion
{ }
}
}
+4 -4
View File
@@ -1,11 +1,11 @@
using System;
using xPushService.Base;
using xDataService.Configuration;
using xContentService.Models.Dtos;
using xIdentityService.Interfaces;
using Microsoft.AspNetCore.SignalR;
using xContentService.Interfaces.Dtos;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using xPushService.Base;
namespace xContentService.Providers.Dtos
{
+11
View File
@@ -15,16 +15,19 @@ namespace xContentService.Providers.Enrichers
{
public class XContentEnricher : IXContentEnricher
{
private readonly IXContentTagProvided tagProvider;
private readonly IXIdentityProvider identityProvider;
private readonly IXContentTitleResourceProvider titleResourceProvider;
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
public XContentEnricher(
IXContentTagProvided tagProvider,
IXIdentityProvider identityProvider,
IXContentTitleResourceProvider titleResourceProvider,
IXContentDescriptionResourceProvider descriptionResourceProvider
)
{
this.tagProvider = tagProvider;
this.identityProvider = identityProvider;
this.titleResourceProvider = titleResourceProvider;
this.descriptionResourceProvider = descriptionResourceProvider;
@@ -105,10 +108,18 @@ namespace xContentService.Providers.Enrichers
contentDescription = descriptionResource.Resource;
}
//
var tags = await tagProvider.GetTags(
id: source.Id,
cancellationToken: cancellationToken
);
//
// Attach Extracted Items ...
var result = source.MapConvert();
result.Owner = owner;
result.Tags = [..tags];
result.Title = contentTitle;
result.TitleResource = titleResource;
result.Description = contentDescription;
+4 -4
View File
@@ -1,10 +1,10 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Db;
using xDataService.Interfaces;
using xDataService.Providers;
using xDataService.Interfaces;
using xDataService.Configuration;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
+3 -3
View File
@@ -1,8 +1,8 @@
using System;
using Microsoft.Extensions.Logging;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xPushService.Base;
using Microsoft.Extensions.Logging;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
@@ -1,8 +1,8 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
using xDataService.Configuration;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
+2 -2
View File
@@ -1,6 +1,6 @@
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Providers;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
@@ -1,8 +1,8 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
using xDataService.Configuration;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
@@ -1,6 +1,6 @@
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Providers;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
@@ -1,10 +1,10 @@
using System;
using Microsoft.AspNetCore.SignalR;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xPushService.Base;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using xPushService.Base;
using Microsoft.AspNetCore.SignalR;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
+3 -3
View File
@@ -1,8 +1,8 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
using xDataService.Configuration;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.Entities
{
@@ -1,8 +1,8 @@
using System;
using xContentService.Constants;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.GraphQL;
using xContentService.Constants;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.GraphQL
{
+3 -3
View File
@@ -1,9 +1,9 @@
using System;
using GraphQL.Types;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.GraphQL;
using xDataService.Configuration;
using xContentService.Models.Entities;
using xContentService.Interfaces.Entities;
namespace xContentService.Providers.GraphQL
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using xContentService.Models.Entities;
using xDataService.GraphQL;
using xContentService.Models.Entities;
namespace xContentService.Providers.GraphQL
{
+4 -4
View File
@@ -1,9 +1,9 @@
using System;
using Microsoft.EntityFrameworkCore;
using xContentService.Configuration.Entities;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xDataService.Providers;
using xDataService.Interfaces;
using Microsoft.EntityFrameworkCore;
using xContentService.Models.Entities;
using xContentService.Configuration.Entities;
namespace xContentService.Providers
{
+5 -4
View File
@@ -419,10 +419,7 @@ namespace xContentService.Providers
//
// Created On ...
if (item.CreatedOn.IsNull())
{
item.CreatedOn = DateTime.UtcNow;
}
item.CreatedOn = DateTime.UtcNow;
//
// Validate Normalized Items ...
@@ -571,6 +568,10 @@ namespace xContentService.Providers
);
}
//
// Handle Update on ...
item.UpdatedAt = DateTime.UtcNow;
//
var result = await provider.UpdateAsync(
id: id,