Merge pull request 'Add physical delete' (#6) from feature/add-physical-delete into development

Reviewed-on: https://gitea.white-enciso.pro/AgileWebs/Core.Inventory.DAL/pulls/6
Reviewed-by: efrain_marin <efrain.marin@agilewebs.com>
Reviewed-by: Sergio Matías <sergio.matias@agilewebs.com>
This commit is contained in:
OscarMmtz 2025-08-08 21:10:36 +00:00
commit 1818de98c0
9 changed files with 148 additions and 0 deletions

View File

@ -186,5 +186,27 @@ namespace Core.Inventory.DAL.API.Controllers
var result = await service.RemoveParentTag(tagId, parentTagId, cancellationToken).ConfigureAwait(false); ;
return Ok(result);
}
/// <summary>
/// Deletes a Tag by its MongoDB identifier.
/// </summary>
/// <param name="id">The Tag MongoDB identifier.</param>
/// <returns>The result of the delete operation.</returns>
/// <response code="200">The Tag deleted successfully.</response>
/// <response code="404">The Tag not found.</response>
/// <response code="500">The service internal error.</response>
[HttpDelete]
[Route("{id}")]
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(TagAdapter), StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteTag([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.DeleteTag(id, cancellationToken).ConfigureAwait(false);
if (result is null) return NotFound("Tag not found");
return Ok(result);
}
}
}

View File

@ -150,5 +150,27 @@ namespace Core.Inventory.DAL.API.Controllers
var result = await service.ChangeTagOverrideStatus(id, newStatus, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Deletes a TagOverride by its MongoDB identifier.
/// </summary>
/// <param name="id">The TagOverride MongoDB identifier.</param>
/// <returns>The result of the delete operation.</returns>
/// <response code="200">The TagOverride deleted successfully.</response>
/// <response code="404">The TagOverride not found.</response>
/// <response code="500">The service internal error.</response>
[HttpDelete]
[Route("{id}")]
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(TagOverrideAdapter), StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteTagOverride([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.DeleteTagOverride(id, cancellationToken).ConfigureAwait(false);
if (result is null) return NotFound("TagOverride not found");
return Ok(result);
}
}
}

View File

@ -150,5 +150,27 @@ namespace Core.Inventory.DAL.API.Controllers
var result = await service.ChangeTagTypeStatus(id, newStatus, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Deletes a TagType by its MongoDB identifier.
/// </summary>
/// <param name="id">The TagType MongoDB identifier.</param>
/// <returns>The result of the delete operation.</returns>
/// <response code="200">The TagType deleted successfully.</response>
/// <response code="404">The TagType not found.</response>
/// <response code="500">The service internal error.</response>
[HttpDelete]
[Route("{id}")]
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(TagTypeAdapter), StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteTagType([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.DeleteTagType(id, cancellationToken).ConfigureAwait(false);
if (result is null) return NotFound("TagType not found");
return Ok(result);
}
}
}

View File

@ -55,5 +55,13 @@ namespace Core.Inventory.Provider.Contracts
/// <returns>A <see cref="{Task{TagOverrideAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
ValueTask<TagOverrideAdapter> UpdateTagOverride(TagOverrideAdapter entity, CancellationToken cancellationToken);
/// <summary>
/// Deletes a TagOverride by its MongoDB identifier.
/// </summary>
/// <param name="tagOverrideId">The TagOverride MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagOverrideAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
ValueTask<TagOverrideAdapter> DeleteTagOverride(string tagOverrideId, CancellationToken cancellationToken);
}
}

View File

@ -71,5 +71,13 @@ namespace Core.Inventory.Provider.Contracts
/// <param name="parentTagId">The identifier of the parentTag to add.</param>
/// <returns>A <see cref="Task{TagAdapter}"/> representing the asynchronous operation, with the updated tag object.</returns>
ValueTask<TagAdapter> RemoveParentTag(string tagId, string parentTagId, CancellationToken cancellationToken);
/// <summary>
/// Deletes a Tag by its MongoDB identifier.
/// </summary>
/// <param name="TagId">The Tag MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
ValueTask<TagAdapter> DeleteTag(string tagId, CancellationToken cancellationToken);
}
}

View File

@ -55,5 +55,13 @@ namespace Core.Inventory.Provider.Contracts
/// <returns>A <see cref="{Task{TagTypeAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
ValueTask<TagTypeAdapter> UpdateTagType(TagTypeAdapter entity, CancellationToken cancellationToken);
/// <summary>
/// Deletes a TagType by its MongoDB identifier.
/// </summary>
/// <param name="tagTypeId">The TagType MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagTypeAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
ValueTask<TagTypeAdapter> DeleteTagType(string tagTypeId, CancellationToken cancellationToken);
}
}

View File

@ -145,5 +145,24 @@ namespace Core.Inventory.Provider.Providers.Inventory
return entity;
}
/// <summary>
/// Deletes a TagOverride by its MongoDB identifier.
/// </summary>
/// <param name="tagOverrideId">The TagOverride MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagOverrideAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
public async ValueTask<TagOverrideAdapter> DeleteTagOverride(string tagOverrideId, CancellationToken cancellationToken)
{
try
{
var entity = await repository.DeleteOneAsync(doc => doc._Id == tagOverrideId);
return entity;
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -188,5 +188,24 @@ namespace Core.Inventory.Provider.Providers.Inventory
return tag;
}
/// <summary>
/// Deletes a Tag by its MongoDB identifier.
/// </summary>
/// <param name="tagId">The Tag MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
public async ValueTask<TagAdapter> DeleteTag(string tagId, CancellationToken cancellationToken)
{
try
{
var entity = await repository.DeleteOneAsync(doc => doc._Id == tagId);
return entity;
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -7,6 +7,7 @@ using Core.Inventory.Provider.Contracts;
using Mapster;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using System.Security.Cryptography;
namespace Core.Inventory.Provider.Providers.Inventory
{
@ -145,5 +146,24 @@ namespace Core.Inventory.Provider.Providers.Inventory
return entity;
}
/// <summary>
/// Deletes a TagType by its MongoDB identifier.
/// </summary>
/// <param name="tagTypeId">The TagType MongoDB identifier.</param>
/// <returns>A <see cref="{Task{TagTypeAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
public async ValueTask<TagTypeAdapter> DeleteTagType(string tagTypeId, CancellationToken cancellationToken)
{
try
{
var entity = await repository.DeleteOneAsync(doc => doc._Id == tagTypeId);
return entity;
}
catch (Exception)
{
throw;
}
}
}
}