feat: added endpoint DeleteProduct
- fix: adapters package updated - fix: status property renamed
This commit is contained in:
		| @@ -73,5 +73,13 @@ namespace Core.Inventory.Provider.Contracts | ||||
|         /// <returns>A <see cref="{Task{ProductAdapter}}"/> representing | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         ValueTask<ProductAdapter> RemoveTagFromProduct(string productId, string tagId, CancellationToken cancellationToken); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes a Product by its MongoDB identifier. | ||||
|         /// </summary> | ||||
|         /// <param name="productId">The Product MongoDB identifier.</param> | ||||
|         /// <returns>A <see cref="{Task{bool}}"/> representing | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         ValueTask<bool> DeleteProduct(string productId, CancellationToken cancellationToken); | ||||
|     } | ||||
| }  | ||||
| @@ -7,7 +7,7 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Adapters.Lib" Version="1.0.11" /> | ||||
|     <PackageReference Include="Adapters.Lib" Version="1.0.13" /> | ||||
|     <PackageReference Include="Core.Blueprint.Mongo" Version="1.0.0" /> | ||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> | ||||
|     <PackageReference Include="Mapster" Version="7.4.0" /> | ||||
|   | ||||
| @@ -125,7 +125,7 @@ namespace Core.Inventory.Provider.Providers.Inventory | ||||
|         public async ValueTask<ProductAdapter> ChangeProductStatus(string id, ProductStatus newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var entity = await repository.FindByIdAsync(id); | ||||
|             entity.Status = newStatus; | ||||
|             entity.ProductStatus = newStatus; | ||||
|  | ||||
|             await repository.ReplaceOneAsync(entity); | ||||
|  | ||||
| @@ -180,7 +180,7 @@ namespace Core.Inventory.Provider.Providers.Inventory | ||||
|         public async ValueTask<ProductAdapter> RemoveTagFromProduct(string productId, string tagId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var product = await repository.FindByIdAsync(productId); | ||||
|              | ||||
|  | ||||
|             if (product != null) | ||||
|             { | ||||
|                 var objectId = ObjectId.Parse(tagId); | ||||
| @@ -190,5 +190,24 @@ namespace Core.Inventory.Provider.Providers.Inventory | ||||
|  | ||||
|             return product; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes a Product by its MongoDB identifier. | ||||
|         /// </summary> | ||||
|         /// <param name="productId">The Product MongoDB identifier.</param> | ||||
|         /// <returns>A <see cref="{Task{bool}}"/> representing | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         public async ValueTask<bool> DeleteProduct(string productId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 await repository.DeleteByIdAsync(productId); | ||||
|                 return true; | ||||
|             } | ||||
|             catch (Exception) | ||||
|             { | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| }  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user