Final fixes for demo
This commit is contained in:
		| @@ -13,6 +13,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Base | |||||||
|     /// </summary> |     /// </summary> | ||||||
|     public class UpdateFurnitureBaseRequest : Notificator, ICommand |     public class UpdateFurnitureBaseRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|  |         public string _Id { get; set; } = null!; | ||||||
|         public string Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         public string ModelName { get; set; } = null!; |         public string ModelName { get; set; } = null!; | ||||||
|         public string Material { get; set; } = null!; |         public string Material { get; set; } = null!; | ||||||
| @@ -26,7 +27,8 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Base | |||||||
|         public List<string>? VariantIds { get; set; } |         public List<string>? VariantIds { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return !string.IsNullOrWhiteSpace(Id) |             return !string.IsNullOrWhiteSpace(_Id) | ||||||
|  |                 && !string.IsNullOrWhiteSpace(Id) | ||||||
|                 && !string.IsNullOrWhiteSpace(ModelName) |                 && !string.IsNullOrWhiteSpace(ModelName) | ||||||
|                 && !string.IsNullOrWhiteSpace(Material) |                 && !string.IsNullOrWhiteSpace(Material) | ||||||
|                 && !string.IsNullOrWhiteSpace(Condition); |                 && !string.IsNullOrWhiteSpace(Condition); | ||||||
|   | |||||||
| @@ -18,10 +18,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant | |||||||
|         public string Currency { get; set; } = "USD"; |         public string Currency { get; set; } = "USD"; | ||||||
|         public int Stock { get; set; } |         public int Stock { get; set; } | ||||||
|  |  | ||||||
|         public Guid CategoryId { get; set; } |         public string CategoryId { get; set; } = string.Empty; | ||||||
|         public Guid ProviderId { get; set; } |         public string ProviderId { get; set; } = string.Empty; | ||||||
|  |  | ||||||
|         public Dictionary<string, object> Attributes { get; set; } = []; |         public Dictionary<string, string> Attributes { get; set; } = []; | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
| @@ -29,9 +29,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant | |||||||
|                 && !string.IsNullOrWhiteSpace(Name) |                 && !string.IsNullOrWhiteSpace(Name) | ||||||
|                 && !string.IsNullOrWhiteSpace(Color) |                 && !string.IsNullOrWhiteSpace(Color) | ||||||
|                 && Price >= 0 |                 && Price >= 0 | ||||||
|                 && Stock >= 0 |                 && Stock >= 0; | ||||||
|                 && CategoryId != Guid.Empty |  | ||||||
|                 && ProviderId != Guid.Empty; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant | |||||||
|     /// </summary> |     /// </summary> | ||||||
|     public class UpdateFurnitureVariantRequest : Notificator, ICommand |     public class UpdateFurnitureVariantRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|  |         public string _Id { get; set; } = null!; | ||||||
|         public string Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         public string ModelId { get; set; } = null!; |         public string ModelId { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
| @@ -23,14 +24,15 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant | |||||||
|         public decimal Price { get; set; } |         public decimal Price { get; set; } | ||||||
|         public string Currency { get; set; } = "USD"; |         public string Currency { get; set; } = "USD"; | ||||||
|  |  | ||||||
|         public Guid CategoryId { get; set; } |         public string CategoryId { get; set; } = string.Empty!; | ||||||
|         public Guid ProviderId { get; set; } |         public string ProviderId { get; set; } = string.Empty!; | ||||||
|  |  | ||||||
|         public Dictionary<string, object> Attributes { get; set; } = []; |         public Dictionary<string, string> Attributes { get; set; } = []; | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return !string.IsNullOrWhiteSpace(Id) && |             return !string.IsNullOrWhiteSpace(_Id) && | ||||||
|  |                    !string.IsNullOrWhiteSpace(Id) && | ||||||
|                    !string.IsNullOrWhiteSpace(ModelId) && |                    !string.IsNullOrWhiteSpace(ModelId) && | ||||||
|                    !string.IsNullOrWhiteSpace(Name) && |                    !string.IsNullOrWhiteSpace(Name) && | ||||||
|                    !string.IsNullOrWhiteSpace(Color) && |                    !string.IsNullOrWhiteSpace(Color) && | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ using Core.Inventory.Application.UseCases.Inventory.Input.Variant; | |||||||
| using Core.Inventory.Application.UseCases.Inventory.Ports; | using Core.Inventory.Application.UseCases.Inventory.Ports; | ||||||
| using Core.Inventory.Application.UseCases.Inventory.Validator.Variant; | using Core.Inventory.Application.UseCases.Inventory.Validator.Variant; | ||||||
| using Core.Inventory.External.Clients; | using Core.Inventory.External.Clients; | ||||||
|  | using Core.Inventory.External.Clients.Adapters; | ||||||
| using Core.Inventory.External.Clients.Requests; | using Core.Inventory.External.Clients.Requests; | ||||||
| using FluentValidation; | using FluentValidation; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| @@ -116,8 +117,10 @@ namespace Core.Inventory.Application.UseCases.Inventory | |||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 var request = new FurnitureBaseRequest |                 var request = new FurnitureBaseAdapter | ||||||
|                 { |                 { | ||||||
|  |                     _Id = command._Id, | ||||||
|  |                     Id = command.Id, | ||||||
|                     BaseDescription = command.BaseDescription, |                     BaseDescription = command.BaseDescription, | ||||||
|                     Condition = command.Condition, |                     Condition = command.Condition, | ||||||
|                     MaintenanceNotes = command.MaintenanceNotes, |                     MaintenanceNotes = command.MaintenanceNotes, | ||||||
| @@ -133,7 +136,7 @@ namespace Core.Inventory.Application.UseCases.Inventory | |||||||
|                     } |                     } | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 var result = await _inventoryDALService.UpdateFurnitureBaseAsync(request, command.Id, cancellationToken); |                 var result = await _inventoryDALService.UpdateFurnitureBaseAsync(command.Id, request, cancellationToken); | ||||||
|                 _basePort.Success(result); |                 _basePort.Success(result); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
| @@ -244,8 +247,10 @@ namespace Core.Inventory.Application.UseCases.Inventory | |||||||
|                     _variantPort.ValidationErrors(command.Notifications); |                     _variantPort.ValidationErrors(command.Notifications); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|                 var request = new FurnitureVariantRequest |                 var request = new FurnitureVariantAdapter | ||||||
|                 { |                 { | ||||||
|  |                     _Id = command._Id, | ||||||
|  |                     Id = command.Id, | ||||||
|                     Stock = command.Stock, |                     Stock = command.Stock, | ||||||
|                     Attributes= command.Attributes, |                     Attributes= command.Attributes, | ||||||
|                     CategoryId = command.CategoryId, |                     CategoryId = command.CategoryId, | ||||||
| @@ -257,7 +262,7 @@ namespace Core.Inventory.Application.UseCases.Inventory | |||||||
|                     Price = command.Price, |                     Price = command.Price, | ||||||
|                     ProviderId = command.ProviderId |                     ProviderId = command.ProviderId | ||||||
|                 }; |                 }; | ||||||
|                 var result = await _inventoryDALService.UpdateFurnitureVariantAsync(request, command.Id, cancellationToken); |                 var result = await _inventoryDALService.UpdateFurnitureVariantAsync(command.Id, request, cancellationToken); | ||||||
|                 _variantPort.Success(result); |                 _variantPort.Success(result); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|   | |||||||
| @@ -8,6 +8,12 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base | |||||||
|     { |     { | ||||||
|         public UpdateFurnitureBaseValidator() |         public UpdateFurnitureBaseValidator() | ||||||
|         { |         { | ||||||
|  |             RuleFor(x => x._Id) | ||||||
|  |                 .NotEmpty().WithMessage("_Id is required."); | ||||||
|  |  | ||||||
|  |             RuleFor(x => x.Id) | ||||||
|  |                 .NotEmpty().WithMessage("Id is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.ModelName) |             RuleFor(x => x.ModelName) | ||||||
|                .NotEmpty().WithMessage("Model name is required."); |                .NotEmpty().WithMessage("Model name is required."); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,10 +23,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant | |||||||
|                 .GreaterThanOrEqualTo(0).WithMessage("Stock must be a non-negative value."); |                 .GreaterThanOrEqualTo(0).WithMessage("Stock must be a non-negative value."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.CategoryId) |             RuleFor(x => x.CategoryId) | ||||||
|                 .NotEqual(Guid.Empty).WithMessage("CategoryId is required."); |                 .NotEmpty().WithMessage("CategoryId is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.ProviderId) |             RuleFor(x => x.ProviderId) | ||||||
|                 .NotEqual(Guid.Empty).WithMessage("ProviderId is required."); |                 .NotEmpty().WithMessage("ProviderId is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.Currency) |             RuleFor(x => x.Currency) | ||||||
|                 .NotEmpty().WithMessage("Currency is required."); |                 .NotEmpty().WithMessage("Currency is required."); | ||||||
|   | |||||||
| @@ -7,6 +7,9 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant | |||||||
|     { |     { | ||||||
|         public UpdateFurnitureVariantValidator() |         public UpdateFurnitureVariantValidator() | ||||||
|         { |         { | ||||||
|  |             RuleFor(x => x._Id) | ||||||
|  |                 .NotEmpty().WithMessage("_Id is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.Id) |             RuleFor(x => x.Id) | ||||||
|                 .NotEmpty().WithMessage("Id is required."); |                 .NotEmpty().WithMessage("Id is required."); | ||||||
|  |  | ||||||
| @@ -29,10 +32,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant | |||||||
|                 .NotEmpty().WithMessage("Currency is required."); |                 .NotEmpty().WithMessage("Currency is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.CategoryId) |             RuleFor(x => x.CategoryId) | ||||||
|                 .NotEqual(Guid.Empty).WithMessage("CategoryId is required."); |                 .NotEmpty().WithMessage("CategoryId is required."); | ||||||
|  |  | ||||||
|             RuleFor(x => x.ProviderId) |             RuleFor(x => x.ProviderId) | ||||||
|                 .NotEqual(Guid.Empty).WithMessage("ProviderId is required."); |                 .NotEmpty().WithMessage("ProviderId is required."); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,19 @@ | |||||||
|  | using Core.Adapters.Lib; | ||||||
|  |  | ||||||
|  | namespace Core.Inventory.External.Clients.Adapters | ||||||
|  | { | ||||||
|  |     public class FurnitureBaseAdapter | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } = null!; | ||||||
|  |         public string Id { get; init; } = null!; | ||||||
|  |         public string ModelName { get; set; } = null!; | ||||||
|  |         public string Material { get; set; } = null!; | ||||||
|  |         public string Condition { get; set; } = null!; | ||||||
|  |         public string? BaseDescription { get; set; } | ||||||
|  |         public string? Representation { get; set; } | ||||||
|  |         public string? MaintenanceNotes { get; set; } | ||||||
|  |  | ||||||
|  |         public Dimensions Dimensions { get; set; } = new(); | ||||||
|  |         public List<string>? VariantIds { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,21 @@ | |||||||
|  | namespace Core.Inventory.External.Clients.Adapters | ||||||
|  | { | ||||||
|  |     public class FurnitureVariantAdapter | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } = null!; | ||||||
|  |         public string Id { get; init; } = null!; | ||||||
|  |         public string ModelId { get; set; } = null!; | ||||||
|  |         public string Name { get; set; } = null!; | ||||||
|  |         public string Color { get; set; } = null!; | ||||||
|  |         public string? Line { get; set; } | ||||||
|  |  | ||||||
|  |         public decimal Price { get; set; } | ||||||
|  |         public string Currency { get; set; } = "USD"; | ||||||
|  |         public int Stock { get; set; } | ||||||
|  |  | ||||||
|  |         public string CategoryId { get; set; } = string.Empty!; | ||||||
|  |         public string ProviderId { get; set; } = string.Empty!; | ||||||
|  |  | ||||||
|  |         public Dictionary<string, string> Attributes { get; set; } = []; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,5 +1,6 @@ | |||||||
| using Core.Adapters.Lib; | using Core.Adapters.Lib; | ||||||
| using Core.Blueprint.Mongo; | using Core.Blueprint.Mongo; | ||||||
|  | using Core.Inventory.External.Clients.Adapters; | ||||||
| using Core.Inventory.External.Clients.Requests; | using Core.Inventory.External.Clients.Requests; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Refit; | using Refit; | ||||||
| @@ -20,7 +21,7 @@ namespace Core.Inventory.External.Clients | |||||||
|         Task<FurnitureBase> CreateFurnitureBaseAsync([FromBody] FurnitureBaseRequest request, CancellationToken cancellationToken = default); |         Task<FurnitureBase> CreateFurnitureBaseAsync([FromBody] FurnitureBaseRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/api/v1/FurnitureBase/{id}")] |         [Put("/api/v1/FurnitureBase/{id}")] | ||||||
|         Task<FurnitureBase> UpdateFurnitureBaseAsync([FromBody] FurnitureBaseRequest request, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<FurnitureBase> UpdateFurnitureBaseAsync([FromRoute] string id, [FromBody] FurnitureBaseAdapter request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/api/v1/FurnitureBase/{mongoId}/{newStatus}/ChangeStatus")] |         [Patch("/api/v1/FurnitureBase/{mongoId}/{newStatus}/ChangeStatus")] | ||||||
|         Task<FurnitureBase> ChangeFurnitureBaseStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<FurnitureBase> ChangeFurnitureBaseStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
| @@ -42,7 +43,7 @@ namespace Core.Inventory.External.Clients | |||||||
|         Task<FurnitureVariant> CreateFurnitureVariantAsync([FromBody] FurnitureVariantRequest request, CancellationToken cancellationToken = default); |         Task<FurnitureVariant> CreateFurnitureVariantAsync([FromBody] FurnitureVariantRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/api/v1/FurnitureVariant/{id}")] |         [Put("/api/v1/FurnitureVariant/{id}")] | ||||||
|         Task<FurnitureVariant> UpdateFurnitureVariantAsync([FromBody] FurnitureVariantRequest request, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<FurnitureVariant> UpdateFurnitureVariantAsync([FromRoute] string id, [FromBody] FurnitureVariantAdapter request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/api/v1/FurnitureVariant/{mongoId}/{newStatus}/ChangeStatus")] |         [Patch("/api/v1/FurnitureVariant/{mongoId}/{newStatus}/ChangeStatus")] | ||||||
|         Task<FurnitureVariant> ChangeFurnitureVariantStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<FurnitureVariant> ChangeFurnitureVariantStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|   | |||||||
| @@ -11,9 +11,9 @@ | |||||||
|         public string Currency { get; set; } = "USD"; |         public string Currency { get; set; } = "USD"; | ||||||
|         public int Stock { get; set; } |         public int Stock { get; set; } | ||||||
|  |  | ||||||
|         public Guid CategoryId { get; set; } |         public string CategoryId { get; set; } = string.Empty!; | ||||||
|         public Guid ProviderId { get; set; } |         public string ProviderId { get; set; } = string.Empty!; | ||||||
|  |  | ||||||
|         public Dictionary<string, object> Attributes { get; set; } = []; |         public Dictionary<string, string> Attributes { get; set; } = []; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Adapters.Lib" Version="1.0.3" /> |     <PackageReference Include="Adapters.Lib" Version="1.0.6" /> | ||||||
|     <PackageReference Include="BuildingBlocks.Library" Version="1.0.0" /> |     <PackageReference Include="BuildingBlocks.Library" Version="1.0.0" /> | ||||||
|     <PackageReference Include="Refit" Version="8.0.0" /> |     <PackageReference Include="Refit" Version="8.0.0" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user