From 18cb238b40b249c5e63668a118c6e3c6a369eb07 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 00:47:44 -0600 Subject: [PATCH 01/11] first version of inventory adapters --- Inventory/Base/InventoryItem.cs | 29 ---------------- Inventory/Common/FurnitureModel.cs | 53 ++++++++++++++++++++++++++++++ Inventory/InventoryItem.cs | 51 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 29 deletions(-) delete mode 100644 Inventory/Base/InventoryItem.cs create mode 100644 Inventory/Common/FurnitureModel.cs create mode 100644 Inventory/InventoryItem.cs diff --git a/Inventory/Base/InventoryItem.cs b/Inventory/Base/InventoryItem.cs deleted file mode 100644 index e45586b..0000000 --- a/Inventory/Base/InventoryItem.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Core.Blueprint.Mongo; -using MongoDB.Bson.Serialization.Attributes; -using System.Text.Json.Serialization; - -namespace Core.Adapters.Lib.Inventory.Base -{ - [CollectionAttributeName("Inventory")] - public class InventoryItem : Document - { - [BsonElement("name")] - [JsonPropertyName("name")] - public string Name { get; set; } - - [BsonElement("description")] - [JsonPropertyName("description")] - public string Description { get; set; } - - [BsonElement("stock")] - [JsonPropertyName("stock")] - public int Stock { get; set; } - - [BsonElement("representation")] - [JsonPropertyName("representation")] - public string Representation { get; set; } - - - public string Company { get; set; } - } -} diff --git a/Inventory/Common/FurnitureModel.cs b/Inventory/Common/FurnitureModel.cs new file mode 100644 index 0000000..64c09d0 --- /dev/null +++ b/Inventory/Common/FurnitureModel.cs @@ -0,0 +1,53 @@ +using Core.Blueprint.Mongo; +using MongoDB.Bson.Serialization.Attributes; +using System.Text.Json.Serialization; + +namespace Core.Adapters.Lib.Inventory.Common +{ + [CollectionAttributeName("Furniture")] + public class FurnitureModel : Document + { + [BsonElement("modelName")] + [JsonPropertyName("modelName")] + public string ModelName { get; set; } + + [BsonElement("material")] + [JsonPropertyName("material")] + public string Material { get; set; } + + [BsonElement("condition")] + [JsonPropertyName("condition")] + public string Condition { get; set; } + + [BsonElement("dimensions")] + [JsonPropertyName("dimensions")] + public Dimensions Dimensions { get; set; } + + [BsonElement("baseDescription")] + [JsonPropertyName("baseDescription")] + public string BaseDescription { get; set; } + + [BsonElement("representation")] + [JsonPropertyName("representation")] + public string Representation { get; set; } + + [BsonElement("maintenanceNotes")] + [JsonPropertyName("maintenanceNotes")] + public string MaintenanceNotes { get; set; } + } + + public class Dimensions + { + [BsonElement("width")] + [JsonPropertyName("width")] + public float Width { get; set; } + + [BsonElement("height")] + [JsonPropertyName("height")] + public float Height { get; set; } + + [BsonElement("depth")] + [JsonPropertyName("depth")] + public float Depth { get; set; } + } +} diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs new file mode 100644 index 0000000..fade486 --- /dev/null +++ b/Inventory/InventoryItem.cs @@ -0,0 +1,51 @@ +using Core.Adapters.Lib.Inventory.Common; +using Core.Blueprint.Mongo; +using MongoDB.Bson.Serialization.Attributes; +using System.Text.Json.Serialization; + +namespace Core.Adapters.Lib.Inventory +{ + [CollectionAttributeName("Inventory")] + public class InventoryItem : FurnitureModel + { + [BsonElement("modelId")] + [JsonPropertyName("modelId")] + public string ModelId { get; set; } // FK a FurnitureModel._id + + [BsonElement("name")] + [JsonPropertyName("name")] + public string Name { get; set; } + + [BsonElement("color")] + [JsonPropertyName("color")] + public string Color { get; set; } + + [BsonElement("line")] + [JsonPropertyName("line")] + public string Line { get; set; } + + [BsonElement("price")] + [JsonPropertyName("price")] + public decimal Price { get; set; } + + [BsonElement("currency")] + [JsonPropertyName("currency")] + public string Currency { get; set; } + + [BsonElement("stock")] + [JsonPropertyName("stock")] + public int Stock { get; set; } + + [BsonElement("categoryId")] + [JsonPropertyName("categoryId")] + public Guid CategoryId { get; set; } + + [BsonElement("providerId")] + [JsonPropertyName("providerId")] + public Guid ProviderId { get; set; } + + [BsonElement("attributes")] + [JsonPropertyName("attributes")] + public Dictionary Attributes { get; set; } = new(); + } +} From e33301f6afea228b474e72193f472026417f647f Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 00:56:21 -0600 Subject: [PATCH 02/11] Fix in structure --- Inventory/{Common => }/FurnitureModel.cs | 2 +- Inventory/InventoryItem.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) rename Inventory/{Common => }/FurnitureModel.cs (97%) diff --git a/Inventory/Common/FurnitureModel.cs b/Inventory/FurnitureModel.cs similarity index 97% rename from Inventory/Common/FurnitureModel.cs rename to Inventory/FurnitureModel.cs index 64c09d0..f08d4ae 100644 --- a/Inventory/Common/FurnitureModel.cs +++ b/Inventory/FurnitureModel.cs @@ -2,7 +2,7 @@ using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; -namespace Core.Adapters.Lib.Inventory.Common +namespace Core.Adapters.Lib.Inventory { [CollectionAttributeName("Furniture")] public class FurnitureModel : Document diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index fade486..3b16abc 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -1,5 +1,4 @@ -using Core.Adapters.Lib.Inventory.Common; -using Core.Blueprint.Mongo; +using Core.Blueprint.Mongo; using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; From e7b25ba91aa2a051bf7940ce3f64a467dadbd952 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 01:00:28 -0600 Subject: [PATCH 03/11] Fixes in code --- Inventory/FurnitureModel.cs | 14 +++++++------- Inventory/InventoryItem.cs | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Inventory/FurnitureModel.cs b/Inventory/FurnitureModel.cs index f08d4ae..30fdb6e 100644 --- a/Inventory/FurnitureModel.cs +++ b/Inventory/FurnitureModel.cs @@ -9,31 +9,31 @@ namespace Core.Adapters.Lib.Inventory { [BsonElement("modelName")] [JsonPropertyName("modelName")] - public string ModelName { get; set; } + public string ModelName { get; set; } = null!; [BsonElement("material")] [JsonPropertyName("material")] - public string Material { get; set; } + public string Material { get; set; } = null!; [BsonElement("condition")] [JsonPropertyName("condition")] - public string Condition { get; set; } + public string Condition { get; set; } = null!; [BsonElement("dimensions")] [JsonPropertyName("dimensions")] - public Dimensions Dimensions { get; set; } + public Dimensions Dimensions { get; set; } = null!; [BsonElement("baseDescription")] [JsonPropertyName("baseDescription")] - public string BaseDescription { get; set; } + public string BaseDescription { get; set; } = null!; [BsonElement("representation")] [JsonPropertyName("representation")] - public string Representation { get; set; } + public string Representation { get; set; } = null!; [BsonElement("maintenanceNotes")] [JsonPropertyName("maintenanceNotes")] - public string MaintenanceNotes { get; set; } + public string MaintenanceNotes { get; set; } = null!; } public class Dimensions diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index 3b16abc..8f63690 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -9,19 +9,19 @@ namespace Core.Adapters.Lib.Inventory { [BsonElement("modelId")] [JsonPropertyName("modelId")] - public string ModelId { get; set; } // FK a FurnitureModel._id + public string ModelId { get; set; } = null!; // FK to FurnitureModel._id [BsonElement("name")] [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get; set; } = null!; [BsonElement("color")] [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get; set; } = null!; [BsonElement("line")] [JsonPropertyName("line")] - public string Line { get; set; } + public string Line { get; set; } = null!; [BsonElement("price")] [JsonPropertyName("price")] @@ -29,7 +29,7 @@ namespace Core.Adapters.Lib.Inventory [BsonElement("currency")] [JsonPropertyName("currency")] - public string Currency { get; set; } + public string Currency { get; set; } = null!; [BsonElement("stock")] [JsonPropertyName("stock")] @@ -45,6 +45,6 @@ namespace Core.Adapters.Lib.Inventory [BsonElement("attributes")] [JsonPropertyName("attributes")] - public Dictionary Attributes { get; set; } = new(); + public Dictionary Attributes { get; set; } = []; } } From f6a80ba2ec469a79bdbc196a9107cccbb6460771 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 01:03:23 -0600 Subject: [PATCH 04/11] Fix in namespace --- Inventory/FurnitureModel.cs | 2 +- Inventory/InventoryItem.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Inventory/FurnitureModel.cs b/Inventory/FurnitureModel.cs index 30fdb6e..8da7253 100644 --- a/Inventory/FurnitureModel.cs +++ b/Inventory/FurnitureModel.cs @@ -2,7 +2,7 @@ using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; -namespace Core.Adapters.Lib.Inventory +namespace Core.Adapters.Lib { [CollectionAttributeName("Furniture")] public class FurnitureModel : Document diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index 8f63690..20b5968 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -2,7 +2,7 @@ using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; -namespace Core.Adapters.Lib.Inventory +namespace Core.Adapters.Lib { [CollectionAttributeName("Inventory")] public class InventoryItem : FurnitureModel From ad7b1bd98371d43290621ce7b45f38106b2fb194 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 01:58:31 -0600 Subject: [PATCH 05/11] re-factor in adapters --- .../{FurnitureModel.cs => FurnitureBase.cs} | 6 +++- Inventory/FurnitureVariant.cs | 26 ++++++++++++++++ Inventory/InventoryItem.cs | 30 ++++--------------- 3 files changed, 37 insertions(+), 25 deletions(-) rename Inventory/{FurnitureModel.cs => FurnitureBase.cs} (89%) create mode 100644 Inventory/FurnitureVariant.cs diff --git a/Inventory/FurnitureModel.cs b/Inventory/FurnitureBase.cs similarity index 89% rename from Inventory/FurnitureModel.cs rename to Inventory/FurnitureBase.cs index 8da7253..cc692b2 100644 --- a/Inventory/FurnitureModel.cs +++ b/Inventory/FurnitureBase.cs @@ -5,7 +5,7 @@ using System.Text.Json.Serialization; namespace Core.Adapters.Lib { [CollectionAttributeName("Furniture")] - public class FurnitureModel : Document + public class FurnitureBase : Document { [BsonElement("modelName")] [JsonPropertyName("modelName")] @@ -34,6 +34,10 @@ namespace Core.Adapters.Lib [BsonElement("maintenanceNotes")] [JsonPropertyName("maintenanceNotes")] public string MaintenanceNotes { get; set; } = null!; + + [BsonElement("variantIds")] + [JsonPropertyName("variantIds")] + public List VariantIds { get; set; } = new(); } public class Dimensions diff --git a/Inventory/FurnitureVariant.cs b/Inventory/FurnitureVariant.cs new file mode 100644 index 0000000..a3bbf57 --- /dev/null +++ b/Inventory/FurnitureVariant.cs @@ -0,0 +1,26 @@ +using Core.Blueprint.Mongo; +using MongoDB.Bson.Serialization.Attributes; +using System.Text.Json.Serialization; + +namespace Core.Adapters.Lib +{ + [CollectionAttributeName("FurnitureVariants")] + public class FurnitureVariant : Document + { + [BsonElement("modelId")] + [JsonPropertyName("modelId")] + public string ModelId { get; set; } = null!; + + [BsonElement("name")] + [JsonPropertyName("name")] + public string Name { get; set; } = null!; + + [BsonElement("color")] + [JsonPropertyName("color")] + public string Color { get; set; } = null!; + + [BsonElement("line")] + [JsonPropertyName("line")] + public string Line { get; set; } = null!; + } +} diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index 20b5968..f5039ca 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -1,27 +1,13 @@ -using Core.Blueprint.Mongo; -using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; -namespace Core.Adapters.Lib +namespace Core.Adapters.Lib.Inventory { - [CollectionAttributeName("Inventory")] - public class InventoryItem : FurnitureModel + public abstract class InventoryItem : Document { - [BsonElement("modelId")] - [JsonPropertyName("modelId")] - public string ModelId { get; set; } = null!; // FK to FurnitureModel._id - - [BsonElement("name")] - [JsonPropertyName("name")] - public string Name { get; set; } = null!; - - [BsonElement("color")] - [JsonPropertyName("color")] - public string Color { get; set; } = null!; - - [BsonElement("line")] - [JsonPropertyName("line")] - public string Line { get; set; } = null!; + [BsonElement("stock")] + [JsonPropertyName("stock")] + public int Stock { get; set; } [BsonElement("price")] [JsonPropertyName("price")] @@ -31,10 +17,6 @@ namespace Core.Adapters.Lib [JsonPropertyName("currency")] public string Currency { get; set; } = null!; - [BsonElement("stock")] - [JsonPropertyName("stock")] - public int Stock { get; set; } - [BsonElement("categoryId")] [JsonPropertyName("categoryId")] public Guid CategoryId { get; set; } From fcfb3e47e8cd900fda2fe0cdee5eca45f77a7ec6 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Sun, 22 Jun 2025 02:23:35 -0600 Subject: [PATCH 06/11] Fix in InventoryItem NameSpace --- Inventory/InventoryItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index f5039ca..2919917 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -1,7 +1,7 @@ using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; -namespace Core.Adapters.Lib.Inventory +namespace Core.Adapters.Lib { public abstract class InventoryItem : Document { From 08cca3a9c0b1ac32845439c0708935b1a56087f1 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Fri, 27 Jun 2025 19:34:39 -0600 Subject: [PATCH 07/11] Fix in inheritance --- Inventory/FurnitureVariant.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventory/FurnitureVariant.cs b/Inventory/FurnitureVariant.cs index a3bbf57..aad1b2a 100644 --- a/Inventory/FurnitureVariant.cs +++ b/Inventory/FurnitureVariant.cs @@ -5,7 +5,7 @@ using System.Text.Json.Serialization; namespace Core.Adapters.Lib { [CollectionAttributeName("FurnitureVariants")] - public class FurnitureVariant : Document + public class FurnitureVariant : InventoryItem { [BsonElement("modelId")] [JsonPropertyName("modelId")] From 20776516fdcf4ac5d39c3a2a386fa85802413be8 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Fri, 27 Jun 2025 20:15:51 -0600 Subject: [PATCH 08/11] Added bsontype --- Inventory/InventoryItem.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index 2919917..b37312b 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -1,4 +1,5 @@ -using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; namespace Core.Adapters.Lib @@ -18,10 +19,12 @@ namespace Core.Adapters.Lib public string Currency { get; set; } = null!; [BsonElement("categoryId")] + [BsonRepresentation(BsonType.String)] [JsonPropertyName("categoryId")] public Guid CategoryId { get; set; } [BsonElement("providerId")] + [BsonRepresentation(BsonType.String)] [JsonPropertyName("providerId")] public Guid ProviderId { get; set; } From 6c1124673326be5c84fd53c12e11183e006f656f Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Fri, 27 Jun 2025 20:21:47 -0600 Subject: [PATCH 09/11] fix Ids type --- Inventory/InventoryItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index b37312b..b057d75 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -21,12 +21,12 @@ namespace Core.Adapters.Lib [BsonElement("categoryId")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("categoryId")] - public Guid CategoryId { get; set; } + public string CategoryId { get; set; } [BsonElement("providerId")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("providerId")] - public Guid ProviderId { get; set; } + public string ProviderId { get; set; } [BsonElement("attributes")] [JsonPropertyName("attributes")] From feee4ebdfaadf15443758a09833838bfde49f609 Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Fri, 27 Jun 2025 20:41:09 -0600 Subject: [PATCH 10/11] Fix type --- Inventory/InventoryItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index b057d75..a91bd6f 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -30,6 +30,6 @@ namespace Core.Adapters.Lib [BsonElement("attributes")] [JsonPropertyName("attributes")] - public Dictionary Attributes { get; set; } = []; + public Dictionary Attributes { get; set; } = []; } } From 4358891b247436680e3937ec6dbda56158f529da Mon Sep 17 00:00:00 2001 From: Ignacio Gomez Date: Fri, 27 Jun 2025 20:51:57 -0600 Subject: [PATCH 11/11] Change type in dictionary --- Inventory/InventoryItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventory/InventoryItem.cs b/Inventory/InventoryItem.cs index a91bd6f..4334902 100644 --- a/Inventory/InventoryItem.cs +++ b/Inventory/InventoryItem.cs @@ -30,6 +30,6 @@ namespace Core.Adapters.Lib [BsonElement("attributes")] [JsonPropertyName("attributes")] - public Dictionary Attributes { get; set; } = []; + public Dictionary Attributes { get; set; } = []; } }