Compare commits
1
Commits
5739b968aa
...
5d9cd2afbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d9cd2afbe |
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,7 +1,7 @@
|
||||
using System;
|
||||
using xPushService.Interfaces;
|
||||
using xContentService.Models.Dtos;
|
||||
using xContentService.Models.Entities;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xContentService.Interfaces.Dtos
|
||||
{
|
||||
|
||||
@@ -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,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,6 +1,6 @@
|
||||
using System;
|
||||
using xContentService.Models.Entities;
|
||||
using xDataService.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,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,6 +1,6 @@
|
||||
using System;
|
||||
using xContentService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
using xContentService.Models.Entities;
|
||||
|
||||
namespace xContentService.Interfaces.Entities
|
||||
{
|
||||
|
||||
@@ -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,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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
using System;
|
||||
using xContentService.Models.Entities;
|
||||
using xDataService.GraphQL;
|
||||
using xContentService.Models.Entities;
|
||||
|
||||
namespace xContentService.Providers.GraphQL
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -571,6 +571,10 @@ namespace xContentService.Providers
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Update on ...
|
||||
item.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
//
|
||||
var result = await provider.UpdateAsync(
|
||||
id: id,
|
||||
|
||||
Reference in New Issue
Block a user