Final fixes for demo

This commit is contained in:
Ignacio Gomez 2025-06-27 23:10:38 -06:00
parent 9effaf3b22
commit e191851982
4 changed files with 10 additions and 8 deletions

View File

@ -45,7 +45,7 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
[BsonElement("categoryId")]
[BsonRepresentation(BsonType.String)]
[JsonPropertyName("categoryId")]
public Guid CategoryId { get; set; }
public string CategoryId { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the provider or vendor identifier of the item.
@ -53,7 +53,7 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
[BsonElement("providerId")]
[BsonRepresentation(BsonType.String)]
[JsonPropertyName("providerId")]
public Guid ProviderId { get; set; }
public string ProviderId { get; set; } = string.Empty;
/// <summary>
/// Gets or sets additional customizable attributes.
@ -61,6 +61,6 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
/// </summary>
[BsonElement("attributes")]
[JsonPropertyName("attributes")]
public Dictionary<string, object> Attributes { get; set; } = [];
public Dictionary<string, string> Attributes { get; set; } = [];
}
}

View File

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Adapters.Lib" Version="1.0.3" />
<PackageReference Include="Adapters.Lib" Version="1.0.8" />
<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" />

View File

@ -22,6 +22,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private readonly CollectionRepository<FurnitureBase> repository;
private readonly IRedisCacheProvider cacheProvider;
private readonly CacheSettings cacheSettings;
private const string getAllCache = "GetAllFurnitureBases";
public FurnitureBaseProvider(
CollectionRepository<FurnitureBase> repository,
@ -72,7 +73,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
/// <returns>A list of <see cref="FurnitureBase"/>.</returns>
public async ValueTask<IEnumerable<FurnitureBase>> GetAllAsync(CancellationToken cancellationToken)
{
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, nameof(GetAllAsync));
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllCache);
var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureBase>>(cacheKey) ?? [];
if (cachedData.Any()) return cachedData;
@ -121,7 +122,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private async Task ResetCollectionCache()
{
//TODO: remove this method when necessary.
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllFurnitureBases");
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllCache);
await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureBase>(), null);
}

View File

@ -23,6 +23,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private readonly CollectionRepository<FurnitureVariant> repository;
private readonly IRedisCacheProvider cacheProvider;
private readonly CacheSettings cacheSettings;
private const string getAllVariantsCache = "GetAllFurnitureVariants";
public FurnitureVariantProvider(
CollectionRepository<FurnitureVariant> repository,
@ -150,7 +151,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
/// <returns>A list of <see cref="FurnitureVariant"/>.</returns>
public async ValueTask<IEnumerable<FurnitureVariant>> GetAllAsync(CancellationToken cancellationToken)
{
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, nameof(GetAllAsync));
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllVariantsCache);
var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureVariant>>(cacheKey) ?? [];
if (cachedData.Any()) return cachedData;
@ -167,7 +168,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private async Task ResetCollectionCache()
{
//TODO: remove this method when necessary.
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllFurnitureVariants");
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllVariantsCache);
await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureVariant>(), null);
}