Initial ...

This commit is contained in:
2026-03-22 14:09:53 +03:30
commit a855ea6b70
33 changed files with 6649 additions and 0 deletions
+324
View File
@@ -0,0 +1,324 @@
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
}
}
@@ -0,0 +1,326 @@
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
}
}
+321
View File
@@ -0,0 +1,321 @@
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
}
}