Compare commits
4 Commits
main
...
542df8a203
| Author | SHA1 | Date | |
|---|---|---|---|
| 542df8a203 | |||
| 0038169f5a | |||
| 24f647f90e | |||
| f76e318f92 |
@@ -7,19 +7,19 @@
|
|||||||
using Core.Blueprint.Mongo;
|
using Core.Blueprint.Mongo;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command to change the status of a furniture base model.
|
/// Command to change the status of a furniture base model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChangeFurnitureBaseStatusRequest : Notificator, ICommand
|
public class ChangeFurnitureBaseStatusRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = null!;
|
public string MongoId { get; set; } = null!;
|
||||||
public StatusEnum Status { get; set; }
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(Id);
|
return !string.IsNullOrWhiteSpace(MongoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input.Common;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Common;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for creating a new furniture base entity.
|
/// Command for creating a new furniture base entity.
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
|
||||||
{
|
{
|
||||||
public class GetAllFurnitureBaseRequest : ICommand
|
public class GetAllFurnitureBaseRequest : ICommand
|
||||||
{
|
{
|
||||||
@@ -5,18 +5,18 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query to retrieve a furniture base by its identifier.
|
/// Query to retrieve a furniture base by its identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GetFurnitureBaseByIdRequest : Notificator, ICommand
|
public class GetFurnitureBaseByIdRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = null!;
|
public string MongoId { get; set; } = null!;
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(Id);
|
return !string.IsNullOrWhiteSpace(MongoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,13 +6,14 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input.Common;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Common;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Base
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for updating an existing furniture base entity.
|
/// Command for updating an existing furniture base entity.
|
||||||
/// </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
|
|||||||
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);
|
||||||
@@ -6,19 +6,19 @@
|
|||||||
using Core.Blueprint.Mongo;
|
using Core.Blueprint.Mongo;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command to change the status of a furniture variant.
|
/// Command to change the status of a furniture variant.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChangeFurnitureVariantStatusRequest : Notificator, ICommand
|
public class ChangeFurnitureVariantStatusRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = null!;
|
public string MongoId { get; set; } = null!;
|
||||||
public StatusEnum Status { get; set; }
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(Id);
|
return !string.IsNullOrWhiteSpace(MongoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
{
|
{
|
||||||
public class CreateFurnitureVariantRequest : Notificator, ICommand
|
public class CreateFurnitureVariantRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
@@ -18,10 +18,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Input
|
|||||||
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
|
|||||||
&& !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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="GetAllFurnitureVariantRequest.cs">
|
||||||
|
// Core.Inventory
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
|
{
|
||||||
|
public class GetAllFurnitureVariantRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate() => true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
{
|
{
|
||||||
public class GetAllFurnitureVariantsByModelIdRequest : Notificator, ICommand
|
public class GetAllFurnitureVariantsByModelIdRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
@@ -5,15 +5,15 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
{
|
{
|
||||||
public class GetFurnitureVariantByIdRequest : Notificator, ICommand
|
public class GetFurnitureVariantByIdRequest : Notificator, ICommand
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = null!;
|
public string MongoId { get; set; } = null!;
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(Id);
|
return !string.IsNullOrWhiteSpace(MongoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="GetVariantsByIdsRequest.cs">
|
||||||
|
// Core.Inventory
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Request to retrieve multiple furniture variants by their identifiers.
|
||||||
|
/// </summary>
|
||||||
|
public class GetFurnitureVariantsByIdsRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string[] Ids { get; set; } = [];
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Ids is not null && Ids.Length > 0 && Ids.All(id => !string.IsNullOrWhiteSpace(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,13 +6,14 @@
|
|||||||
|
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Input
|
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for updating an existing furniture variant.
|
/// Command for updating an existing furniture 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
|
|||||||
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) &&
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
|
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.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;
|
||||||
@@ -20,7 +23,9 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
IComponentHandler<UpdateFurnitureVariantRequest>,
|
IComponentHandler<UpdateFurnitureVariantRequest>,
|
||||||
IComponentHandler<GetFurnitureVariantByIdRequest>,
|
IComponentHandler<GetFurnitureVariantByIdRequest>,
|
||||||
IComponentHandler<GetAllFurnitureVariantsByModelIdRequest>,
|
IComponentHandler<GetAllFurnitureVariantsByModelIdRequest>,
|
||||||
IComponentHandler<ChangeFurnitureVariantStatusRequest>
|
IComponentHandler<ChangeFurnitureVariantStatusRequest>,
|
||||||
|
IComponentHandler<GetFurnitureVariantsByIdsRequest>,
|
||||||
|
IComponentHandler<GetAllFurnitureVariantRequest>
|
||||||
{
|
{
|
||||||
// FurnitureBase
|
// FurnitureBase
|
||||||
private readonly IFurnitureBasePort _basePort;
|
private readonly IFurnitureBasePort _basePort;
|
||||||
@@ -112,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,
|
||||||
@@ -129,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)
|
||||||
@@ -161,7 +168,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
var result = await _inventoryDALService.GetFurnitureBaseByIdAsync(command.Id, cancellationToken);
|
var result = await _inventoryDALService.GetFurnitureBaseByIdAsync(command.MongoId, cancellationToken);
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
_basePort.NoContentSuccess();
|
_basePort.NoContentSuccess();
|
||||||
@@ -186,7 +193,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await _inventoryDALService.ChangeFurnitureBaseStatusAsync(command.Id, command.Status, cancellationToken);
|
var result = await _inventoryDALService.ChangeFurnitureBaseStatusAsync(command.MongoId, command.Status, cancellationToken);
|
||||||
_basePort.Success(result);
|
_basePort.Success(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -240,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,
|
||||||
@@ -253,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)
|
||||||
@@ -267,7 +276,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
var result = await _inventoryDALService.GetFurnitureVariantByIdAsync(command.Id, cancellationToken);
|
var result = await _inventoryDALService.GetFurnitureVariantByIdAsync(command.MongoId, cancellationToken);
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
_variantPort.NoContentSuccess();
|
_variantPort.NoContentSuccess();
|
||||||
@@ -300,6 +309,34 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetFurnitureVariantsByIdsRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(new GetFurnitureVariantsByIdsValidator()))
|
||||||
|
{
|
||||||
|
_variantPort.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _inventoryDALService.GetFurnitureVariantsByIdsAsync([.. command.Ids], cancellationToken);
|
||||||
|
|
||||||
|
if (result is null || !result.Any())
|
||||||
|
{
|
||||||
|
_variantPort.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_variantPort.Success([.. result]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _variantPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask ExecuteAsync(ChangeFurnitureVariantStatusRequest command, CancellationToken cancellationToken = default)
|
public async ValueTask ExecuteAsync(ChangeFurnitureVariantStatusRequest command, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -310,7 +347,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
_variantPort.ValidationErrors(command.Notifications);
|
_variantPort.ValidationErrors(command.Notifications);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = await _inventoryDALService.ChangeFurnitureVariantStatusAsync(command.Id, command.Status, cancellationToken);
|
var result = await _inventoryDALService.ChangeFurnitureVariantStatusAsync(command.MongoId, command.Status, cancellationToken);
|
||||||
_variantPort.Success(result);
|
_variantPort.Success(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -319,6 +356,24 @@ namespace Core.Inventory.Application.UseCases.Inventory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllFurnitureVariantRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _inventoryDALService.GetAllFurnitureVariantAsync(cancellationToken);
|
||||||
|
if (!result.Any())
|
||||||
|
{
|
||||||
|
_variantPort.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_variantPort.Success([.. result]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _basePort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base
|
||||||
{
|
{
|
||||||
public class ChangeFurnitureBaseStatusValidator : AbstractValidator<ChangeFurnitureBaseStatusRequest>
|
public class ChangeFurnitureBaseStatusValidator : AbstractValidator<ChangeFurnitureBaseStatusRequest>
|
||||||
{
|
{
|
||||||
public ChangeFurnitureBaseStatusValidator()
|
public ChangeFurnitureBaseStatusValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Id)
|
RuleFor(x => x.MongoId)
|
||||||
.NotEmpty().WithMessage("Id is required.");
|
.NotEmpty().WithMessage("Id is required.");
|
||||||
|
|
||||||
RuleFor(x => x.Status)
|
RuleFor(x => x.Status)
|
||||||
@@ -3,11 +3,11 @@
|
|||||||
// Core.Inventory
|
// Core.Inventory
|
||||||
// </copyright>
|
// </copyright>
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Validator.Common;
|
using Core.Inventory.Application.UseCases.Inventory.Validator.Common;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base
|
||||||
{
|
{
|
||||||
public class CreateFurnitureBaseValidator : AbstractValidator<CreateFurnitureBaseRequest>
|
public class CreateFurnitureBaseValidator : AbstractValidator<CreateFurnitureBaseRequest>
|
||||||
{
|
{
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base
|
||||||
{
|
{
|
||||||
public class GetFurnitureBaseByIdValidator : AbstractValidator<GetFurnitureBaseByIdRequest>
|
public class GetFurnitureBaseByIdValidator : AbstractValidator<GetFurnitureBaseByIdRequest>
|
||||||
{
|
{
|
||||||
public GetFurnitureBaseByIdValidator()
|
public GetFurnitureBaseByIdValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Id)
|
RuleFor(x => x.MongoId)
|
||||||
.NotEmpty().WithMessage("Id is required.");
|
.NotEmpty().WithMessage("Id is required.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Validator.Common;
|
using Core.Inventory.Application.UseCases.Inventory.Validator.Common;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Base
|
||||||
{
|
{
|
||||||
public class UpdateFurnitureBaseValidator : AbstractValidator<UpdateFurnitureBaseRequest>
|
public class UpdateFurnitureBaseValidator : AbstractValidator<UpdateFurnitureBaseRequest>
|
||||||
{
|
{
|
||||||
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.");
|
||||||
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
{
|
{
|
||||||
public class ChangeFurnitureVariantStatusValidator : AbstractValidator<ChangeFurnitureVariantStatusRequest>
|
public class ChangeFurnitureVariantStatusValidator : AbstractValidator<ChangeFurnitureVariantStatusRequest>
|
||||||
{
|
{
|
||||||
public ChangeFurnitureVariantStatusValidator()
|
public ChangeFurnitureVariantStatusValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Id)
|
RuleFor(x => x.MongoId)
|
||||||
.NotEmpty().WithMessage("Id is required.");
|
.NotEmpty().WithMessage("Id is required.");
|
||||||
|
|
||||||
RuleFor(x => x.Status)
|
RuleFor(x => x.Status)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
{
|
{
|
||||||
public class CreateFurnitureVariantValidator : AbstractValidator<CreateFurnitureVariantRequest>
|
public class CreateFurnitureVariantValidator : AbstractValidator<CreateFurnitureVariantRequest>
|
||||||
{
|
{
|
||||||
@@ -23,10 +23,10 @@ namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
|||||||
.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.");
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
{
|
{
|
||||||
public class GetAllFurnitureVariantsByModelIdValidator : AbstractValidator<GetAllFurnitureVariantsByModelIdRequest>
|
public class GetAllFurnitureVariantsByModelIdValidator : AbstractValidator<GetAllFurnitureVariantsByModelIdRequest>
|
||||||
{
|
{
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
{
|
{
|
||||||
public class GetFurnitureVariantByIdValidator : AbstractValidator<GetFurnitureVariantByIdRequest>
|
public class GetFurnitureVariantByIdValidator : AbstractValidator<GetFurnitureVariantByIdRequest>
|
||||||
{
|
{
|
||||||
public GetFurnitureVariantByIdValidator()
|
public GetFurnitureVariantByIdValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Id)
|
RuleFor(x => x.MongoId)
|
||||||
.NotEmpty().WithMessage("Id is required.");
|
.NotEmpty().WithMessage("Id is required.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="GetVariantsByIdsValidator.cs">
|
||||||
|
// Core.Inventory
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Validator for <see cref="GetFurnitureVariantsByIdsRequest"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class GetFurnitureVariantsByIdsValidator : AbstractValidator<GetFurnitureVariantsByIdsRequest>
|
||||||
|
{
|
||||||
|
public GetFurnitureVariantsByIdsValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Ids)
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("The list of IDs must not be null.")
|
||||||
|
.Must(ids => ids.Length!=0)
|
||||||
|
.WithMessage("At least one ID must be provided.")
|
||||||
|
.Must(ids => ids.All(id => !string.IsNullOrWhiteSpace(id)))
|
||||||
|
.WithMessage("All IDs must be non-empty strings.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace Core.Inventory.Application.UseCases.Inventory.Validator
|
namespace Core.Inventory.Application.UseCases.Inventory.Validator.Variant
|
||||||
{
|
{
|
||||||
public class UpdateFurnitureVariantValidator : AbstractValidator<UpdateFurnitureVariantRequest>
|
public class UpdateFurnitureVariantValidator : AbstractValidator<UpdateFurnitureVariantRequest>
|
||||||
{
|
{
|
||||||
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
|
|||||||
.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;
|
||||||
@@ -13,37 +14,42 @@ namespace Core.Inventory.External.Clients
|
|||||||
[Get("/api/v1/FurnitureBase")]
|
[Get("/api/v1/FurnitureBase")]
|
||||||
Task<IEnumerable<FurnitureBase>> GetAllFurnitureBaseAsync(CancellationToken cancellationToken = default);
|
Task<IEnumerable<FurnitureBase>> GetAllFurnitureBaseAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
[Get("/api/v1/FurnitureBase/{id}")]
|
[Get("/api/v1/FurnitureBase/{mongoId}")]
|
||||||
Task<FurnitureBase> GetFurnitureBaseByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
Task<FurnitureBase> GetFurnitureBaseByIdAsync([FromRoute] string mongoId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
[Post("/api/v1/FurnitureBase")]
|
[Post("/api/v1/FurnitureBase")]
|
||||||
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/{id}/{newStatus}/ChangeStatus")]
|
[Patch("/api/v1/FurnitureBase/{mongoId}/{newStatus}/ChangeStatus")]
|
||||||
Task<FurnitureBase> ChangeFurnitureBaseStatusAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
Task<FurnitureBase> ChangeFurnitureBaseStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region FurnitureVariant
|
#region FurnitureVariant
|
||||||
|
|
||||||
[Get("/api/v1/FurnitureVariant/{modelId}")]
|
[Get("/api/v1/FurnitureVariant/ByModel/{modelId}")]
|
||||||
Task<IEnumerable<FurnitureVariant>> GetAllVariantsByModelIdAsync([FromRoute] string modelId, CancellationToken cancellationToken = default);
|
Task<IEnumerable<FurnitureVariant>> GetAllVariantsByModelIdAsync([FromRoute] string modelId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
[Get("/api/v1/FurnitureVariant/{id}/byId")]
|
[Get("/api/v1/FurnitureVariant/{mongoId}")]
|
||||||
Task<FurnitureVariant> GetFurnitureVariantByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
Task<FurnitureVariant> GetFurnitureVariantByIdAsync([FromRoute] string mongoId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/api/v1/FurnitureVariant/ByIds")]
|
||||||
|
Task<IEnumerable<FurnitureVariant>> GetFurnitureVariantsByIdsAsync([Body] string[] ids, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
[Post("/api/v1/FurnitureVariant")]
|
[Post("/api/v1/FurnitureVariant")]
|
||||||
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/{id}/{newStatus}/ChangeStatus")]
|
[Patch("/api/v1/FurnitureVariant/{mongoId}/{newStatus}/ChangeStatus")]
|
||||||
Task<FurnitureVariant> ChangeFurnitureVariantStatusAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
Task<FurnitureVariant> ChangeFurnitureVariantStatusAsync([FromRoute] string mongoId, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/api/v1/FurnitureVariant")]
|
||||||
|
Task<IEnumerable<FurnitureVariant>> GetAllFurnitureVariantAsync(CancellationToken cancellationToken = default);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Asp.Versioning;
|
using Asp.Versioning;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Ports;
|
using Core.Inventory.Application.UseCases.Inventory.Ports;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -10,30 +10,20 @@ namespace Core.Inventory.Service.API.Controllers
|
|||||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class FurnitureBaseController : ControllerBase
|
public class FurnitureBaseController(
|
||||||
|
IComponentHandler<GetFurnitureBaseByIdRequest> getByIdHandler,
|
||||||
|
IComponentHandler<GetAllFurnitureBaseRequest> getAllHandler,
|
||||||
|
IComponentHandler<CreateFurnitureBaseRequest> createHandler,
|
||||||
|
IComponentHandler<UpdateFurnitureBaseRequest> updateHandler,
|
||||||
|
IComponentHandler<ChangeFurnitureBaseStatusRequest> changeStatusHandler,
|
||||||
|
IFurnitureBasePort port) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IComponentHandler<GetFurnitureBaseByIdRequest> _getByIdHandler;
|
private readonly IComponentHandler<GetFurnitureBaseByIdRequest> _getByIdHandler = getByIdHandler;
|
||||||
private readonly IComponentHandler<GetAllFurnitureBaseRequest> _getAllHandler;
|
private readonly IComponentHandler<GetAllFurnitureBaseRequest> _getAllHandler = getAllHandler;
|
||||||
private readonly IComponentHandler<CreateFurnitureBaseRequest> _createHandler;
|
private readonly IComponentHandler<CreateFurnitureBaseRequest> _createHandler = createHandler;
|
||||||
private readonly IComponentHandler<UpdateFurnitureBaseRequest> _updateHandler;
|
private readonly IComponentHandler<UpdateFurnitureBaseRequest> _updateHandler = updateHandler;
|
||||||
private readonly IComponentHandler<ChangeFurnitureBaseStatusRequest> _changeStatusHandler;
|
private readonly IComponentHandler<ChangeFurnitureBaseStatusRequest> _changeStatusHandler = changeStatusHandler;
|
||||||
private readonly IFurnitureBasePort _port;
|
private readonly IFurnitureBasePort _port = port;
|
||||||
|
|
||||||
public FurnitureBaseController(
|
|
||||||
IComponentHandler<GetFurnitureBaseByIdRequest> getByIdHandler,
|
|
||||||
IComponentHandler<GetAllFurnitureBaseRequest> getAllHandler,
|
|
||||||
IComponentHandler<CreateFurnitureBaseRequest> createHandler,
|
|
||||||
IComponentHandler<UpdateFurnitureBaseRequest> updateHandler,
|
|
||||||
IComponentHandler<ChangeFurnitureBaseStatusRequest> changeStatusHandler,
|
|
||||||
IFurnitureBasePort port)
|
|
||||||
{
|
|
||||||
_getByIdHandler= getByIdHandler;
|
|
||||||
_getAllHandler= getAllHandler;
|
|
||||||
_createHandler= createHandler;
|
|
||||||
_updateHandler= updateHandler;
|
|
||||||
_changeStatusHandler= changeStatusHandler;
|
|
||||||
_port= port;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("GetAll")]
|
[HttpGet("GetAll")]
|
||||||
public async Task<IActionResult> GetAllAsync(CancellationToken cancellationToken)
|
public async Task<IActionResult> GetAllAsync(CancellationToken cancellationToken)
|
||||||
@@ -45,7 +35,7 @@ namespace Core.Inventory.Service.API.Controllers
|
|||||||
[HttpPost("GetById")]
|
[HttpPost("GetById")]
|
||||||
public async Task<IActionResult> GetByIdAsync([FromBody] GetFurnitureBaseByIdRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetByIdAsync([FromBody] GetFurnitureBaseByIdRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(request?.Id)) return BadRequest("Furniture base identifier is required");
|
if (string.IsNullOrEmpty(request?.MongoId)) return BadRequest("Furniture base identifier is required");
|
||||||
|
|
||||||
await _getByIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
await _getByIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
return _port.ViewModel;
|
return _port.ViewModel;
|
||||||
@@ -68,7 +58,7 @@ namespace Core.Inventory.Service.API.Controllers
|
|||||||
[HttpPatch("ChangeStatus")]
|
[HttpPatch("ChangeStatus")]
|
||||||
public async Task<IActionResult> ChangeStatusAsync([FromBody] ChangeFurnitureBaseStatusRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> ChangeStatusAsync([FromBody] ChangeFurnitureBaseStatusRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(request?.Id)) return BadRequest("Furniture base identifier is required");
|
if (string.IsNullOrEmpty(request?.MongoId)) return BadRequest("Furniture base identifier is required");
|
||||||
|
|
||||||
await _changeStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
await _changeStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
return _port.ViewModel;
|
return _port.ViewModel;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Asp.Versioning;
|
using Asp.Versioning;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Variant;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Ports;
|
using Core.Inventory.Application.UseCases.Inventory.Ports;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -12,38 +12,59 @@ namespace Core.Inventory.Service.API.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FurnitureVariantController(
|
public class FurnitureVariantController(
|
||||||
IComponentHandler<GetFurnitureVariantByIdRequest> getByIdHandler,
|
IComponentHandler<GetFurnitureVariantByIdRequest> getByIdHandler,
|
||||||
IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> getAllHandler,
|
IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> getAllMyModelIdHandler,
|
||||||
IComponentHandler<CreateFurnitureVariantRequest> createHandler,
|
IComponentHandler<CreateFurnitureVariantRequest> createHandler,
|
||||||
IComponentHandler<UpdateFurnitureVariantRequest> updateHandler,
|
IComponentHandler<UpdateFurnitureVariantRequest> updateHandler,
|
||||||
IComponentHandler<ChangeFurnitureVariantStatusRequest> changeStatusHandler,
|
IComponentHandler<ChangeFurnitureVariantStatusRequest> changeStatusHandler,
|
||||||
|
IComponentHandler<GetFurnitureVariantsByIdsRequest> getByIdsHandler,
|
||||||
|
IComponentHandler<GetAllFurnitureVariantRequest> getAllHandler,
|
||||||
IFurnitureVariantPort port) : ControllerBase
|
IFurnitureVariantPort port) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IComponentHandler<GetFurnitureVariantByIdRequest> _getByIdHandler = getByIdHandler;
|
private readonly IComponentHandler<GetFurnitureVariantByIdRequest> _getByIdHandler = getByIdHandler;
|
||||||
private readonly IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> _getAllHandler = getAllHandler;
|
private readonly IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> _getAllByModelIdHandler = getAllMyModelIdHandler;
|
||||||
private readonly IComponentHandler<CreateFurnitureVariantRequest> _createHandler = createHandler;
|
private readonly IComponentHandler<CreateFurnitureVariantRequest> _createHandler = createHandler;
|
||||||
private readonly IComponentHandler<UpdateFurnitureVariantRequest> _updateHandler = updateHandler;
|
private readonly IComponentHandler<UpdateFurnitureVariantRequest> _updateHandler = updateHandler;
|
||||||
private readonly IComponentHandler<ChangeFurnitureVariantStatusRequest> _changeStatusHandler = changeStatusHandler;
|
private readonly IComponentHandler<ChangeFurnitureVariantStatusRequest> _changeStatusHandler = changeStatusHandler;
|
||||||
|
private readonly IComponentHandler<GetFurnitureVariantsByIdsRequest> _getByIdsHandler = getByIdsHandler;
|
||||||
|
private readonly IComponentHandler<GetAllFurnitureVariantRequest> _getAllHandler = getAllHandler;
|
||||||
private readonly IFurnitureVariantPort _port = port;
|
private readonly IFurnitureVariantPort _port = port;
|
||||||
|
|
||||||
[HttpGet("GetAllByModelId")]
|
[HttpGet("GetAll")]
|
||||||
public async Task<IActionResult> GetAllAsync([FromQuery] string modelId, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetAllAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(modelId)) return BadRequest("Model ID is required");
|
await _getAllHandler.ExecuteAsync(new GetAllFurnitureVariantRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
return _port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
var request = new GetAllFurnitureVariantsByModelIdRequest { ModelId = modelId };
|
[HttpPost("GetAllByModelId")]
|
||||||
await _getAllHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
public async Task<IActionResult> GetAllByModelIdAsync([FromBody] GetAllFurnitureVariantsByModelIdRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request?.ModelId)) return BadRequest("Model ID is required");
|
||||||
|
|
||||||
|
await _getAllByModelIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
return _port.ViewModel;
|
return _port.ViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("GetById")]
|
[HttpPost("GetById")]
|
||||||
public async Task<IActionResult> GetByIdAsync([FromBody] GetFurnitureVariantByIdRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> GetByIdAsync([FromBody] GetFurnitureVariantByIdRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(request?.Id)) return BadRequest("Furniture variant identifier is required");
|
if (string.IsNullOrEmpty(request?.MongoId)) return BadRequest("Furniture variant identifier is required");
|
||||||
|
|
||||||
await _getByIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
await _getByIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
return _port.ViewModel;
|
return _port.ViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("GetByIds")]
|
||||||
|
public async Task<IActionResult> GetByIdsAsync([FromBody] GetFurnitureVariantsByIdsRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (request?.Ids is null || request.Ids.Length == 0)
|
||||||
|
return BadRequest("At least one furniture variant ID must be provided.");
|
||||||
|
|
||||||
|
await _getByIdsHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
return _port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost("Create")]
|
[HttpPost("Create")]
|
||||||
public async Task<IActionResult> CreateAsync([FromBody] CreateFurnitureVariantRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> CreateAsync([FromBody] CreateFurnitureVariantRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -61,7 +82,7 @@ namespace Core.Inventory.Service.API.Controllers
|
|||||||
[HttpPatch("ChangeStatus")]
|
[HttpPatch("ChangeStatus")]
|
||||||
public async Task<IActionResult> ChangeStatusAsync([FromBody] ChangeFurnitureVariantStatusRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> ChangeStatusAsync([FromBody] ChangeFurnitureVariantStatusRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(request?.Id)) return BadRequest("Furniture variant identifier is required");
|
if (string.IsNullOrEmpty(request?.MongoId)) return BadRequest("Furniture variant identifier is required");
|
||||||
|
|
||||||
await _changeStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
await _changeStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
return _port.ViewModel;
|
return _port.ViewModel;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using Core.Inventory.Application.UseCases.Inventory;
|
using Core.Inventory.Application.UseCases.Inventory;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Adapter;
|
using Core.Inventory.Application.UseCases.Inventory.Adapter;
|
||||||
using Core.Inventory.Application.UseCases.Inventory.Input;
|
using Core.Inventory.Application.UseCases.Inventory.Input.Base;
|
||||||
|
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;
|
using Core.Inventory.Application.UseCases.Inventory.Validator.Base;
|
||||||
|
using Core.Inventory.Application.UseCases.Inventory.Validator.Variant;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Lib.Architecture.BuildingBlocks;
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
@@ -42,6 +44,8 @@ namespace Core.Inventory.Service.API.Extensions
|
|||||||
services.AddScoped<IComponentHandler<CreateFurnitureVariantRequest>, InventoryHandler>();
|
services.AddScoped<IComponentHandler<CreateFurnitureVariantRequest>, InventoryHandler>();
|
||||||
services.AddScoped<IComponentHandler<UpdateFurnitureVariantRequest>, InventoryHandler>();
|
services.AddScoped<IComponentHandler<UpdateFurnitureVariantRequest>, InventoryHandler>();
|
||||||
services.AddScoped<IComponentHandler<ChangeFurnitureVariantStatusRequest>, InventoryHandler>();
|
services.AddScoped<IComponentHandler<ChangeFurnitureVariantStatusRequest>, InventoryHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetFurnitureVariantsByIdsRequest>, InventoryHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllFurnitureVariantRequest>, InventoryHandler>();
|
||||||
|
|
||||||
services.AddValidatorsFromAssemblyContaining<CreateFurnitureVariantValidator>();
|
services.AddValidatorsFromAssemblyContaining<CreateFurnitureVariantValidator>();
|
||||||
services.AddScoped<IValidator<CreateFurnitureVariantRequest>, CreateFurnitureVariantValidator>();
|
services.AddScoped<IValidator<CreateFurnitureVariantRequest>, CreateFurnitureVariantValidator>();
|
||||||
@@ -57,6 +61,9 @@ namespace Core.Inventory.Service.API.Extensions
|
|||||||
|
|
||||||
services.AddValidatorsFromAssemblyContaining<GetAllFurnitureVariantsByModelIdValidator>();
|
services.AddValidatorsFromAssemblyContaining<GetAllFurnitureVariantsByModelIdValidator>();
|
||||||
services.AddScoped<IValidator<GetAllFurnitureVariantsByModelIdRequest>, GetAllFurnitureVariantsByModelIdValidator>();
|
services.AddScoped<IValidator<GetAllFurnitureVariantsByModelIdRequest>, GetAllFurnitureVariantsByModelIdValidator>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<GetFurnitureVariantsByIdsValidator>();
|
||||||
|
services.AddScoped<IValidator<GetFurnitureVariantsByIdsRequest>, GetFurnitureVariantsByIdsValidator>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
|||||||
Reference in New Issue
Block a user