Compare commits
3
Commits
5739b968aa
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18bd6b462e | ||
|
|
7802ff9561 | ||
|
|
5d9cd2afbe |
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
||||||
using xContentService.Constants;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xContentService.Constants;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
namespace xContentService.Configuration.Entities
|
namespace xContentService.Configuration.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Providers;
|
using xCommons.Providers;
|
||||||
using xTagService.Interfaces;
|
using xCommons.Extensions;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xCommons.Configurations;
|
using xCommons.Configurations;
|
||||||
using xPushService.Interfaces;
|
|
||||||
using xTagService.Controllers;
|
using xTagService.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using xContentService.Interfaces;
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -15,15 +19,17 @@ using xContentService.Interfaces.Controllers;
|
|||||||
|
|
||||||
namespace xContentService.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,
|
ILogger<XBaseProvidedHasTagControllerBase<XContent, XContentDto, Guid, XContentDtoHub>> logger,
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
XValidationProvider validationProvider,
|
XValidationProvider validationProvider,
|
||||||
IXBaseProvided<XContent, XContentDto, Guid, XContentDtoHub> provider,
|
IXContentProvider provider,
|
||||||
IXTagProvided<XContent, XContentDto, Guid, XContentDtoHub> tagProvided,
|
IXContentTagProvided tagProvided,
|
||||||
Func<IQueryable<XContent>, IOrderedQueryable<XContent>> defaultOrderBuilder = null,
|
Func<IQueryable<XContent>, IOrderedQueryable<XContent>> defaultOrderBuilder = null,
|
||||||
Func<IQueryable<XContent>, IIncludableQueryable<XContent, object>> defaultIncludeBuilder = null
|
Func<IQueryable<XContent>, IIncludableQueryable<XContent, object>> defaultIncludeBuilder = null
|
||||||
) : base(
|
) : base(
|
||||||
@@ -36,6 +42,72 @@ namespace xContentService.Controllers
|
|||||||
defaultOrderBuilder,
|
defaultOrderBuilder,
|
||||||
defaultIncludeBuilder
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using GraphQL.Types;
|
using GraphQL.Types;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xContentService.Providers.Entities;
|
|
||||||
using xContentService.Providers.GraphQL;
|
|
||||||
using xDataService.Db;
|
using xDataService.Db;
|
||||||
using xDataService.Models;
|
using xDataService.Models;
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Providers.GraphQL;
|
||||||
|
using xContentService.Providers.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Helpers
|
namespace xContentService.Helpers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using xTagService.Interfaces;
|
using xTagService.Interfaces;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xContentService.Providers.Dtos;
|
using xContentService.Providers.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
@@ -8,6 +11,18 @@ namespace xContentService.Interfaces.Controllers
|
|||||||
{
|
{
|
||||||
public interface IXContentProviderController : IXBaseProvidedHasTagController<XContent, XContentDto, Guid, XContentDtoHub>
|
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,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using xPushService.Interfaces;
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xPushService.Interfaces;
|
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Dtos
|
namespace xContentService.Interfaces.Dtos
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,60 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
using System.Collections.Generic;
|
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Dtos
|
namespace xContentService.Interfaces.Dtos
|
||||||
{
|
{
|
||||||
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
|
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Dtos;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xContentService.Providers.Dtos;
|
|
||||||
using xPushService.Interfaces;
|
using xPushService.Interfaces;
|
||||||
|
using xContentService.Models.Dtos;
|
||||||
|
using xContentService.Providers.Dtos;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Dtos
|
namespace xContentService.Interfaces.Dtos
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xPushService.Interfaces;
|
using xPushService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using xPushService.Interfaces;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xContentService.Providers.Entities;
|
using xContentService.Providers.Entities;
|
||||||
using xPushService.Interfaces;
|
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Entities
|
namespace xContentService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,21 @@ namespace xContentService.Interfaces
|
|||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
string language = null,
|
string language = null,
|
||||||
CancellationToken cancellationToken = default
|
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
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,15 @@ namespace xContentService.Models.Dtos
|
|||||||
{
|
{
|
||||||
public string OwnerId { get; set; }
|
public string OwnerId { get; set; }
|
||||||
public virtual XPersonDto Owner { get; set; }
|
public virtual XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public virtual XResourceDto TitleResource { get; set; }
|
public virtual XResourceDto TitleResource { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public virtual XResourceDto DescriptionResource { get; set; }
|
public virtual XResourceDto DescriptionResource { get; set; }
|
||||||
|
|
||||||
|
public string[] Tags { get; set; }
|
||||||
|
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
public DateTime UpdatedAt { get; set; }
|
public DateTime UpdatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using xPushService.Base;
|
||||||
|
using xContentService.Models.Dtos;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using xContentService.Interfaces.Dtos;
|
using xContentService.Interfaces.Dtos;
|
||||||
using xContentService.Models.Dtos;
|
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xPushService.Base;
|
|
||||||
|
|
||||||
namespace xContentService.Providers.Dtos
|
namespace xContentService.Providers.Dtos
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using System.Linq;
|
|
||||||
using xModels.Dtos;
|
|
||||||
using System.Threading;
|
|
||||||
using xCommons.Extensions;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xContentService.Interfaces;
|
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xIdentityService.Interfaces;
|
|
||||||
using xIdentityService.Extensions;
|
|
||||||
using xContentService.Interfaces.Dtos;
|
using xContentService.Interfaces.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xContentService.Interfaces.Entities;
|
using xContentService.Interfaces.Entities;
|
||||||
@@ -19,156 +11,13 @@ namespace xContentService.Providers.Dtos
|
|||||||
{
|
{
|
||||||
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
|
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
|
||||||
{
|
{
|
||||||
private readonly IXIdentityProvider identityProvider;
|
|
||||||
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
|
||||||
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
|
||||||
|
|
||||||
public XContentRepositoryService(
|
public XContentRepositoryService(
|
||||||
IXContentRepository repository,
|
IXContentRepository repository,
|
||||||
IXIdentityProvider identityProvider,
|
|
||||||
IXContentTitleResourceProvider titleResourceProvider,
|
|
||||||
IXContentDescriptionResourceProvider descriptionResourceProvider,
|
|
||||||
IEnumerable<Profile> mapperProfiles = null
|
IEnumerable<Profile> mapperProfiles = null
|
||||||
) : base(
|
) : base(
|
||||||
repository,
|
repository,
|
||||||
mapperProfiles
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using xPushService.Base;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Dtos;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using xContentService.Interfaces.Dtos;
|
using xContentService.Interfaces.Dtos;
|
||||||
using xContentService.Models.Dtos;
|
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xDataService.Configuration;
|
|
||||||
using xIdentityService.Interfaces;
|
|
||||||
using xPushService.Base;
|
|
||||||
|
|
||||||
namespace xContentService.Providers.Dtos
|
namespace xContentService.Providers.Dtos
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,16 +15,19 @@ namespace xContentService.Providers.Enrichers
|
|||||||
{
|
{
|
||||||
public class XContentEnricher : IXContentEnricher
|
public class XContentEnricher : IXContentEnricher
|
||||||
{
|
{
|
||||||
|
private readonly IXContentTagProvided tagProvider;
|
||||||
private readonly IXIdentityProvider identityProvider;
|
private readonly IXIdentityProvider identityProvider;
|
||||||
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
||||||
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
||||||
|
|
||||||
public XContentEnricher(
|
public XContentEnricher(
|
||||||
|
IXContentTagProvided tagProvider,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
IXContentTitleResourceProvider titleResourceProvider,
|
IXContentTitleResourceProvider titleResourceProvider,
|
||||||
IXContentDescriptionResourceProvider descriptionResourceProvider
|
IXContentDescriptionResourceProvider descriptionResourceProvider
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
this.tagProvider = tagProvider;
|
||||||
this.identityProvider = identityProvider;
|
this.identityProvider = identityProvider;
|
||||||
this.titleResourceProvider = titleResourceProvider;
|
this.titleResourceProvider = titleResourceProvider;
|
||||||
this.descriptionResourceProvider = descriptionResourceProvider;
|
this.descriptionResourceProvider = descriptionResourceProvider;
|
||||||
@@ -105,10 +108,18 @@ namespace xContentService.Providers.Enrichers
|
|||||||
contentDescription = descriptionResource.Resource;
|
contentDescription = descriptionResource.Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var tags = await tagProvider.GetTags(
|
||||||
|
id: source.Id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Attach Extracted Items ...
|
// Attach Extracted Items ...
|
||||||
var result = source.MapConvert();
|
var result = source.MapConvert();
|
||||||
result.Owner = owner;
|
result.Owner = owner;
|
||||||
|
result.Tags = [..tags];
|
||||||
result.Title = contentTitle;
|
result.Title = contentTitle;
|
||||||
result.TitleResource = titleResource;
|
result.TitleResource = titleResource;
|
||||||
result.Description = contentDescription;
|
result.Description = contentDescription;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xDataService.Db;
|
using xDataService.Db;
|
||||||
using xDataService.Interfaces;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xPushService.Base;
|
using xPushService.Base;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using xPushService.Base;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
using xDataService.Configuration;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using xPushService.Base;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.Entities
|
namespace xContentService.Providers.Entities
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Constants;
|
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.GraphQL;
|
using xDataService.GraphQL;
|
||||||
|
using xContentService.Constants;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.GraphQL
|
namespace xContentService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using GraphQL.Types;
|
using GraphQL.Types;
|
||||||
using xContentService.Interfaces.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xDataService.GraphQL;
|
using xDataService.GraphQL;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Interfaces.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.GraphQL
|
namespace xContentService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.GraphQL;
|
using xDataService.GraphQL;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers.GraphQL
|
namespace xContentService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using xContentService.Configuration.Entities;
|
|
||||||
using xContentService.Models.Entities;
|
|
||||||
using xDataService.Interfaces;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using xContentService.Models.Entities;
|
||||||
|
using xContentService.Configuration.Entities;
|
||||||
|
|
||||||
namespace xContentService.Providers
|
namespace xContentService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -419,10 +419,7 @@ namespace xContentService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Created On ...
|
// Created On ...
|
||||||
if (item.CreatedOn.IsNull())
|
item.CreatedOn = DateTime.UtcNow;
|
||||||
{
|
|
||||||
item.CreatedOn = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Normalized Items ...
|
// Validate Normalized Items ...
|
||||||
@@ -571,6 +568,10 @@ namespace xContentService.Providers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Update on ...
|
||||||
|
item.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
//
|
//
|
||||||
var result = await provider.UpdateAsync(
|
var result = await provider.UpdateAsync(
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
Reference in New Issue
Block a user