Final fixes for demo

This commit is contained in:
2025-06-27 23:11:01 -06:00
parent 0038169f5a
commit 542df8a203
12 changed files with 82 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
/// </summary>
public class UpdateFurnitureBaseRequest : Notificator, ICommand
{
public string _Id { get; set; } = null!;
public string Id { get; set; } = null!;
public string ModelName { 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 bool Validate()
{
return !string.IsNullOrWhiteSpace(Id)
return !string.IsNullOrWhiteSpace(_Id)
&& !string.IsNullOrWhiteSpace(Id)
&& !string.IsNullOrWhiteSpace(ModelName)
&& !string.IsNullOrWhiteSpace(Material)
&& !string.IsNullOrWhiteSpace(Condition);

View File

@@ -18,10 +18,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
public string Currency { get; set; } = "USD";
public int Stock { get; set; }
public Guid CategoryId { get; set; }
public Guid ProviderId { get; set; }
public string CategoryId { get; set; } = string.Empty;
public string ProviderId { get; set; } = string.Empty;
public Dictionary<string, object> Attributes { get; set; } = [];
public Dictionary<string, string> Attributes { get; set; } = [];
public bool Validate()
{
@@ -29,9 +29,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
&& !string.IsNullOrWhiteSpace(Name)
&& !string.IsNullOrWhiteSpace(Color)
&& Price >= 0
&& Stock >= 0
&& CategoryId != Guid.Empty
&& ProviderId != Guid.Empty;
&& Stock >= 0;
}
}
}

View File

@@ -13,6 +13,7 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
/// </summary>
public class UpdateFurnitureVariantRequest : Notificator, ICommand
{
public string _Id { get; set; } = null!;
public string Id { get; set; } = null!;
public string ModelId { 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 string Currency { get; set; } = "USD";
public Guid CategoryId { get; set; }
public Guid ProviderId { get; set; }
public string CategoryId { get; set; } = string.Empty!;
public string ProviderId { get; set; } = string.Empty!;
public Dictionary<string, object> Attributes { get; set; } = [];
public Dictionary<string, string> Attributes { get; set; } = [];
public bool Validate()
{
return !string.IsNullOrWhiteSpace(Id) &&
return !string.IsNullOrWhiteSpace(_Id) &&
!string.IsNullOrWhiteSpace(Id) &&
!string.IsNullOrWhiteSpace(ModelId) &&
!string.IsNullOrWhiteSpace(Name) &&
!string.IsNullOrWhiteSpace(Color) &&

View File

@@ -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.Validator.Variant;
using Core.Inventory.External.Clients;
using Core.Inventory.External.Clients.Adapters;
using Core.Inventory.External.Clients.Requests;
using FluentValidation;
using Lib.Architecture.BuildingBlocks;
@@ -116,8 +117,10 @@ namespace Core.Inventory.Application.UseCases.Inventory
return;
}
var request = new FurnitureBaseRequest
var request = new FurnitureBaseAdapter
{
_Id = command._Id,
Id = command.Id,
BaseDescription = command.BaseDescription,
Condition = command.Condition,
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);
}
catch (Exception ex)
@@ -244,8 +247,10 @@ namespace Core.Inventory.Application.UseCases.Inventory
_variantPort.ValidationErrors(command.Notifications);
return;
}
var request = new FurnitureVariantRequest
var request = new FurnitureVariantAdapter
{
_Id = command._Id,
Id = command.Id,
Stock = command.Stock,
Attributes= command.Attributes,
CategoryId = command.CategoryId,
@@ -257,7 +262,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
Price = command.Price,
ProviderId = command.ProviderId
};
var result = await _inventoryDALService.UpdateFurnitureVariantAsync(request, command.Id, cancellationToken);
var result = await _inventoryDALService.UpdateFurnitureVariantAsync(command.Id, request, cancellationToken);
_variantPort.Success(result);
}
catch (Exception ex)

View File

@@ -8,6 +8,12 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base
{
public UpdateFurnitureBaseValidator()
{
RuleFor(x => x._Id)
.NotEmpty().WithMessage("_Id is required.");
RuleFor(x => x.Id)
.NotEmpty().WithMessage("Id is required.");
RuleFor(x => x.ModelName)
.NotEmpty().WithMessage("Model name is required.");

View File

@@ -23,10 +23,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
.GreaterThanOrEqualTo(0).WithMessage("Stock must be a non-negative value.");
RuleFor(x => x.CategoryId)
.NotEqual(Guid.Empty).WithMessage("CategoryId is required.");
.NotEmpty().WithMessage("CategoryId is required.");
RuleFor(x => x.ProviderId)
.NotEqual(Guid.Empty).WithMessage("ProviderId is required.");
.NotEmpty().WithMessage("ProviderId is required.");
RuleFor(x => x.Currency)
.NotEmpty().WithMessage("Currency is required.");

View File

@@ -7,6 +7,9 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
{
public UpdateFurnitureVariantValidator()
{
RuleFor(x => x._Id)
.NotEmpty().WithMessage("_Id is required.");
RuleFor(x => x.Id)
.NotEmpty().WithMessage("Id is required.");
@@ -29,10 +32,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
.NotEmpty().WithMessage("Currency is required.");
RuleFor(x => x.CategoryId)
.NotEqual(Guid.Empty).WithMessage("CategoryId is required.");
.NotEmpty().WithMessage("CategoryId is required.");
RuleFor(x => x.ProviderId)
.NotEqual(Guid.Empty).WithMessage("ProviderId is required.");
.NotEmpty().WithMessage("ProviderId is required.");
}
}
}