refactor new ...
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xAiService.Controllers;
|
||||
using xAiService.Interfaces;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
|
||||
namespace xApi.Controllers.V1
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class AiController : XAiServiceControllerBase, IXAiServiceControllerBase
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public AiController(
|
||||
ILogger<AiController> logger,
|
||||
IXAiService aiService,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
aiService,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Text Actions ...
|
||||
[HttpGet("Ask")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<string>> Ask(
|
||||
[FromQuery] string prompt,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return await base.Ask(
|
||||
prompt: prompt,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("AskStream")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AskStream(
|
||||
[FromQuery] string prompt,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return await base.AskStream(
|
||||
prompt: prompt,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityHelper;
|
||||
using xServices.TermsConditions.Interfaces;
|
||||
|
||||
namespace xApi.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementing Terms and Conditions Action Provider ...
|
||||
/// </summary>
|
||||
public partial class ConfigurationsController : IXTermsConditionsControllerActions
|
||||
{
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Terms/Languages")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> TermsLanguages()
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.TermsLanguages();
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Has Terms and Conditions based on Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language">if null, used Default Language ...</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Terms/{language}/Has")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<bool>> HasTerms(
|
||||
[FromRoute] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.HasTerms(
|
||||
language: language
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Terms and Conditions for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language">if null, used Default Language ...</param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Terms/{language}")]
|
||||
public async Task<ActionResult<string>> GetTerms(
|
||||
[FromRoute] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.GetTerms(
|
||||
language: language
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Terms and Conditions for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="terms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<string>> AddTerms(
|
||||
[FromRoute] string language,
|
||||
[FromQuery] string terms
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.AddTerms(
|
||||
terms: terms,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Terms and Conditions of Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<bool>> RemoveTerms(
|
||||
[FromRoute] string language
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.RemoveTerms(
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Terms and Conditions of Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="terms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<bool>> UpdateTerms(
|
||||
[FromRoute] string language,
|
||||
[FromQuery] string terms
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.UpdateTerms(
|
||||
terms: terms,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityService.Interfaces;
|
||||
using xServices.TermsConditions.Interfaces;
|
||||
|
||||
namespace xApi.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides all Configuration related Actions such as String resources and Terms and Configurations ...
|
||||
/// </summary>
|
||||
public partial class ConfigurationsController : XIBaseV1Controller
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
public IXTermsComditionsProvider TermsProvider { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
public ConfigurationsController(
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXTermsComditionsProvider termsProvider,
|
||||
ILogger<ConfigurationsController> logger
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{
|
||||
//
|
||||
TermsProvider = termsProvider;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xDataService.Interfaces;
|
||||
using xFileService.Interfaces.Entities;
|
||||
using xFileService.Models.Entities;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
public class FilesController : XIBaseV1EntityHubController<XFile, Guid>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public FilesController(
|
||||
ILogger<FilesController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXFileRepository repository,
|
||||
IHubContext<XBaseEntityHub<XFile, Guid>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFile>> Get(
|
||||
[FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFile>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFile>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFile>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFile>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Add(
|
||||
[FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> AddOrUpdate(
|
||||
[FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Update(
|
||||
[FromRoute] Guid id, [FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Remove(
|
||||
[FromRoute] Guid id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,326 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple XString Entity Controller ...
|
||||
/// </summary>
|
||||
public class StringsController : XIBaseV1EntityHubController<XString, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public StringsController(
|
||||
ILogger<StringsController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXStringRepository repository,
|
||||
IHubContext<XBaseEntityHub<XString, int>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XString>> Get(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XString>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XString>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XString>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XString>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Add(
|
||||
[FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
// Handle Sending Push Notification ...
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> AddOrUpdate(
|
||||
[FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
// Handle Sending Push Notification ...
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Update(
|
||||
[FromRoute] int id, [FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Remove(
|
||||
[FromRoute] int id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
using xTagService.Interfaces.Entities;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
public class TagsController : XIBaseV1EntityHubController<XTag, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public TagsController(
|
||||
ILogger<TagsController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXTagRepository repository,
|
||||
IHubContext<XBaseEntityHub<XTag, int>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTag>> Get(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTag>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTag>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTag>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XTag>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Add(
|
||||
[FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> AddOrUpdate(
|
||||
[FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Update(
|
||||
[FromRoute] int id, [FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Remove(
|
||||
[FromRoute] int id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xFileService.Controllers;
|
||||
using xFileService.Interfaces;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class FilesController : XFileServiceControllerBase, IXFileServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public FilesController(
|
||||
ILogger<FilesController> logger,
|
||||
IXFileProvider fileProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
fileProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tools ...
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Stream/ById")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Stream(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Stream/ByName")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Stream(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Download/ById")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Download(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Download/ByName")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Download(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload Files ...
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[RequestSizeLimit(966_367_641)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> Upload(
|
||||
[FromForm] IFormFileCollection files
|
||||
)
|
||||
{
|
||||
return await base.Upload(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Files ...
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
/// [HttpDelete("Remove")]
|
||||
[HttpDelete("")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<Guid>>> Remove(
|
||||
[FromQuery] string ids
|
||||
)
|
||||
{
|
||||
return await base.Remove(ids);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Model ...
|
||||
/// <summary>
|
||||
/// Get Specified File Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFileDto>> Get(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Exists File Models ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query/Owned")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> QueryOwned(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.QueryOwned(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tags ...
|
||||
/// <summary>
|
||||
/// Attach Tag to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/Attach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tag From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/Detach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attach Tags to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/AttachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tags From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/DetachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags of Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Tags")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetTags(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.GetTags(id);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,468 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Controllers;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class StringsController : XStringServiceControllerBase, IXStringServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public StringsController(
|
||||
ILogger<StringsController> logger,
|
||||
IXStringProvider stringProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
stringProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Implementing Actions ...
|
||||
//
|
||||
#region Retrievers ...
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Languages ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Languages")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetLanguages()
|
||||
{
|
||||
return await base.GetLanguages();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Resource Exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("IsResourceExists")]
|
||||
public override async Task<ActionResult<bool>> IsResourceExists(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.IsResourceExists(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
[AllowAnonymous]
|
||||
public override async Task<ActionResult<XStringDto>> Get(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Get(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Translation of Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ResourceValue")]
|
||||
public override async Task<ActionResult<string>> GetResourceValue(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.GetResourceValue(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an Specified Resource Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Resources")]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> GetResources(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResources(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource Items as XResourceDto Presentation ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("AsResource")]
|
||||
public override async Task<ActionResult<XResourceDto>> GetResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResource(resource);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// Query Resource IDs ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("QueryResourceIds")]
|
||||
public override ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return base.QueryResourceIds(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified Language Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLanguageResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XStringDto>>> QueryLanguageResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLanguageResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Locale Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLocaleResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XLocaleResourceDto>>> QueryLocaleResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLocaleResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update Actions ...
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Add")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Add(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Add(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Update")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Update(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Update(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> AddOrUpdate(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdate(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.UpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Specified Entitiy ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddOrUpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.UpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource By Locale ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update all XResourceDto(s) Locales ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> AddByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
return await base.AddByResource(item);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove Actions ...
|
||||
/// <summary>
|
||||
/// Remove all Specified Language's Resources ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLanguage")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveLanguageResources(
|
||||
[FromQuery] string language
|
||||
)
|
||||
{
|
||||
return await base.RemoveLanguageResources(language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Specified Resource Ids instances ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLocales")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> RemoveResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.RemoveResource(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Remove")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Remove(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Remove(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Resource of Specified XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("RemoveResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.RemoveByResource(item);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Controllers;
|
||||
using xTagService.Interfaces;
|
||||
using xTagService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class TagsController : XTagServiceControllerBase
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public TagsController(
|
||||
ILogger<TagsController> logger,
|
||||
IXTagProvider tagProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
tagProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Add Tag by Providing Dto ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Add(
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Add(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Tag ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Update(id, model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Tag by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTagDto>> Remove(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Remove(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public override async Task<ActionResult<XTagDto>> Get(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by it's Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetTag")]
|
||||
public override async Task<ActionResult<XTagDto>> GetTag(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.GetTag(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tag by Providing a query on Label ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindOne")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> FindOne(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindOne(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tags By Providing Query on Labels ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> FindMany(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindMany(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags based on Query Model ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XTagDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by Providing Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("IsTagExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsTagExists(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.IsTagExists(tag);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-10
@@ -22,16 +22,12 @@ using xDataService.Configuration;
|
||||
using xDataService.Constants;
|
||||
using xDataService.DI;
|
||||
using xDataService.Interfaces;
|
||||
using xFileService.Hubs;
|
||||
using xHttpService.DI;
|
||||
using xIdentityService.DI;
|
||||
using xPushHelper.DI;
|
||||
using xPushService.DI;
|
||||
using xPushService.Helpers;
|
||||
using xServices.DI;
|
||||
using xServices.TermsConditions.Push;
|
||||
using xStringService.Hubs;
|
||||
using xTagService.Hubs;
|
||||
|
||||
namespace xApi
|
||||
{
|
||||
@@ -250,12 +246,6 @@ namespace xApi
|
||||
//
|
||||
var helper = new XPushServiceHelper();
|
||||
|
||||
//
|
||||
helper.AddHub<XTermsHub>("termsHub");
|
||||
helper.AddHub<XTagEntityHub>("tagEntityHub");
|
||||
helper.AddHub<XFileEntityHub>("fileEntityHub");
|
||||
helper.AddHub<XStringEntityHub>("stringEntityHub");
|
||||
|
||||
//
|
||||
app.UseXPushService(helper);
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user