diff --git a/src/Api/Company.Api/Company.Api.csproj b/src/Api/Company.Api/Company.Api.csproj index c152e631..0f063ec1 100644 --- a/src/Api/Company.Api/Company.Api.csproj +++ b/src/Api/Company.Api/Company.Api.csproj @@ -28,6 +28,7 @@ + diff --git a/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.Designer.cs b/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.Designer.cs deleted file mode 100644 index 3ed1ee89..00000000 --- a/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.Designer.cs +++ /dev/null @@ -1,293 +0,0 @@ -// -using System; -using Company.Api.Products; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Company.Api.Migrations -{ - [DbContext(typeof(ProductContext))] - [Migration("20230528151110_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.5"); - - modelBuilder.Entity("Company.Api.Products.Dtos.ProductDto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Headline") - .HasColumnType("TEXT"); - - b.Property("Images") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("VariantTypes") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - Description = "Improve your well-being with Product One", - Headline = "A great product for great people", - Images = "[\"images\\\\products\\\\the_product_one.png\"]", - Name = "The Product One", - VariantTypes = "[\"Size\",\"Colour\"]" - }, - new - { - Id = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - Description = "Improve your mindfulness with Product Two", - Headline = "A brilliant product for brilliant people", - Images = "[\"images\\\\products\\\\the_product_two.png\"]", - Name = "The Product Two", - VariantTypes = "[\"Magnitude\",\"Emotion\"]" - }); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.VariantDto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("ProductId") - .HasColumnType("TEXT"); - - b.Property("VariantTypeValues") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Variants"); - - b.HasData( - new - { - Id = new Guid("5c863956-2891-4530-8bda-218b456e0b8b"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Green\"}" - }, - new - { - Id = new Guid("cb064427-54b4-47fb-a66b-95831bfa9b55"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Greener\"}" - }, - new - { - Id = new Guid("2901d199-c8ef-4200-9d3b-826d2256b5a1"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Greenest\"}" - }, - new - { - Id = new Guid("86e66430-6260-49fc-aeb4-771caee74ce6"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Green\"}" - }, - new - { - Id = new Guid("0788c61e-9944-4e6c-8a3c-c33c1e89f1be"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Greener\"}" - }, - new - { - Id = new Guid("28b5525d-c920-44ba-9e36-990432589d83"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Greenest\"}" - }, - new - { - Id = new Guid("2e72ffb3-4da2-4108-93f3-8f2128c99dc1"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Excited\"}" - }, - new - { - Id = new Guid("3facedd3-8fb4-4757-bbc5-af9fee02fadc"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Happy\"}" - }, - new - { - Id = new Guid("f87421b2-c1c9-4c6b-9e97-440763b5f735"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Flattered\"}" - }, - new - { - Id = new Guid("db9d3fea-4d12-4b9a-8e2a-0d5b53572708"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Excited\"}" - }, - new - { - Id = new Guid("5f3b4bef-3cbc-40bf-bca5-0e52f9d9bde8"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Happy\"}" - }, - new - { - Id = new Guid("51e94e79-392c-4753-886a-e751cff703a6"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Flattered\"}" - }); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.VariantDto", b => - { - b.HasOne("Company.Api.Products.Dtos.ProductDto", "Product") - .WithMany("Variants") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Company.Api.Products.Dtos.PriceDto", "Price", b1 => - { - b1.Property("VariantDtoId") - .HasColumnType("TEXT"); - - b1.Property("DealPriceGBP") - .HasColumnType("TEXT"); - - b1.Property("Details") - .HasColumnType("TEXT"); - - b1.Property("FullPriceGBP") - .HasColumnType("TEXT"); - - b1.HasKey("VariantDtoId"); - - b1.ToTable("Variants"); - - b1.WithOwner() - .HasForeignKey("VariantDtoId"); - - b1.HasData( - new - { - VariantDtoId = new Guid("5c863956-2891-4530-8bda-218b456e0b8b"), - DealPriceGBP = 64.99m, - Details = "33% off while stocks last!", - FullPriceGBP = 97m - }, - new - { - VariantDtoId = new Guid("cb064427-54b4-47fb-a66b-95831bfa9b55"), - DealPriceGBP = 54.94m, - Details = "33% off while stocks last!", - FullPriceGBP = 82m - }, - new - { - VariantDtoId = new Guid("2901d199-c8ef-4200-9d3b-826d2256b5a1"), - DealPriceGBP = 35.51m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 53m - }, - new - { - VariantDtoId = new Guid("86e66430-6260-49fc-aeb4-771caee74ce6"), - DealPriceGBP = 16.75m, - Details = "33% off while stocks last!", - FullPriceGBP = 25m - }, - new - { - VariantDtoId = new Guid("0788c61e-9944-4e6c-8a3c-c33c1e89f1be"), - DealPriceGBP = 16.08m, - Details = "33% off today!", - FullPriceGBP = 24m - }, - new - { - VariantDtoId = new Guid("28b5525d-c920-44ba-9e36-990432589d83"), - DealPriceGBP = 54.27m, - Details = "33% off today!", - FullPriceGBP = 81m - }, - new - { - VariantDtoId = new Guid("2e72ffb3-4da2-4108-93f3-8f2128c99dc1"), - DealPriceGBP = 6.70m, - Details = "33% off while stocks last!", - FullPriceGBP = 10m - }, - new - { - VariantDtoId = new Guid("3facedd3-8fb4-4757-bbc5-af9fee02fadc"), - DealPriceGBP = 3.35m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 5m - }, - new - { - VariantDtoId = new Guid("f87421b2-c1c9-4c6b-9e97-440763b5f735"), - DealPriceGBP = 66.33m, - Details = "33% off today!", - FullPriceGBP = 99m - }, - new - { - VariantDtoId = new Guid("db9d3fea-4d12-4b9a-8e2a-0d5b53572708"), - DealPriceGBP = 16.75m, - Details = "33% off while stocks last!", - FullPriceGBP = 25m - }, - new - { - VariantDtoId = new Guid("5f3b4bef-3cbc-40bf-bca5-0e52f9d9bde8"), - DealPriceGBP = 22.78m, - Details = "33% off while stocks last!", - FullPriceGBP = 34m - }, - new - { - VariantDtoId = new Guid("51e94e79-392c-4753-886a-e751cff703a6"), - DealPriceGBP = 49.58m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 74m - }); - }); - - b.Navigation("Price"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.ProductDto", b => - { - b.Navigation("Variants"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.cs b/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.cs deleted file mode 100644 index e1860e45..00000000 --- a/src/Api/Company.Api/Migrations/20230528151110_InitialCreate.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace Company.Api.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true), - Headline = table.Column(type: "TEXT", nullable: true), - Description = table.Column(type: "TEXT", nullable: true), - VariantTypes = table.Column(type: "TEXT", nullable: false), - Images = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Variants", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - ProductId = table.Column(type: "TEXT", nullable: false), - VariantTypeValues = table.Column(type: "TEXT", nullable: false), - Price_FullPriceGBP = table.Column(type: "TEXT", nullable: true), - Price_DealPriceGBP = table.Column(type: "TEXT", nullable: true), - Price_Details = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Variants", x => x.Id); - table.ForeignKey( - name: "FK_Variants_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "Products", - columns: new[] { "Id", "Description", "Headline", "Images", "Name", "VariantTypes" }, - values: new object[,] - { - { new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "Improve your mindfulness with Product Two", "A brilliant product for brilliant people", "[\"images\\\\products\\\\the_product_two.png\"]", "The Product Two", "[\"Magnitude\",\"Emotion\"]" }, - { new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "Improve your well-being with Product One", "A great product for great people", "[\"images\\\\products\\\\the_product_one.png\"]", "The Product One", "[\"Size\",\"Colour\"]" } - }); - - migrationBuilder.InsertData( - table: "Variants", - columns: new[] { "Id", "Price_DealPriceGBP", "Price_Details", "Price_FullPriceGBP", "ProductId", "VariantTypeValues" }, - values: new object[,] - { - { new Guid("0788c61e-9944-4e6c-8a3c-c33c1e89f1be"), 16.08m, "33% off today!", 24m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Big\",\"Colour\":\"Greener\"}" }, - { new Guid("28b5525d-c920-44ba-9e36-990432589d83"), 54.27m, "33% off today!", 81m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Big\",\"Colour\":\"Greenest\"}" }, - { new Guid("2901d199-c8ef-4200-9d3b-826d2256b5a1"), 35.51m, "2/3 off for a limited time!", 53m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Small\",\"Colour\":\"Greenest\"}" }, - { new Guid("2e72ffb3-4da2-4108-93f3-8f2128c99dc1"), 6.70m, "33% off while stocks last!", 10m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Small\",\"Emotion\":\"Excited\"}" }, - { new Guid("3facedd3-8fb4-4757-bbc5-af9fee02fadc"), 3.35m, "2/3 off for a limited time!", 5m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Small\",\"Emotion\":\"Happy\"}" }, - { new Guid("51e94e79-392c-4753-886a-e751cff703a6"), 49.58m, "2/3 off for a limited time!", 74m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Vast\",\"Emotion\":\"Flattered\"}" }, - { new Guid("5c863956-2891-4530-8bda-218b456e0b8b"), 64.99m, "33% off while stocks last!", 97m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Small\",\"Colour\":\"Green\"}" }, - { new Guid("5f3b4bef-3cbc-40bf-bca5-0e52f9d9bde8"), 22.78m, "33% off while stocks last!", 34m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Vast\",\"Emotion\":\"Happy\"}" }, - { new Guid("86e66430-6260-49fc-aeb4-771caee74ce6"), 16.75m, "33% off while stocks last!", 25m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Big\",\"Colour\":\"Green\"}" }, - { new Guid("cb064427-54b4-47fb-a66b-95831bfa9b55"), 54.94m, "33% off while stocks last!", 82m, new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), "{\"Size\":\"Small\",\"Colour\":\"Greener\"}" }, - { new Guid("db9d3fea-4d12-4b9a-8e2a-0d5b53572708"), 16.75m, "33% off while stocks last!", 25m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Vast\",\"Emotion\":\"Excited\"}" }, - { new Guid("f87421b2-c1c9-4c6b-9e97-440763b5f735"), 66.33m, "33% off today!", 99m, new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), "{\"Magnitude\":\"Small\",\"Emotion\":\"Flattered\"}" } - }); - - migrationBuilder.CreateIndex( - name: "IX_Variants_ProductId", - table: "Variants", - column: "ProductId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Variants"); - - migrationBuilder.DropTable( - name: "Products"); - } - } -} diff --git a/src/Api/Company.Api/Migrations/20240628134706_initialCreate.Designer.cs b/src/Api/Company.Api/Migrations/20240628134706_initialCreate.Designer.cs new file mode 100644 index 00000000..2a229670 --- /dev/null +++ b/src/Api/Company.Api/Migrations/20240628134706_initialCreate.Designer.cs @@ -0,0 +1,293 @@ +// +using System; +using Company.Api.PetRocks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Company.Api.Migrations +{ + [DbContext(typeof(PetRockContext))] + [Migration("20240628134706_initialCreate")] + partial class initialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.PetRockDto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Catchphrase") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Images") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("VariantTypes") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("PetRocks"); + + b.HasData( + new + { + Id = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + Catchphrase = "Rolling through life one pebble at a time.", + Description = "Meet Pebble Dash, your adventurous little companion! Small but full of energy, Pebble Dash is always ready to roll into new adventures. With a smooth surface and a perfectly rounded shape, this pebble loves to explore the world and bring joy wherever it goes. Whether it's a playful dash across the desk or a calming presence on your nightstand, Pebble Dash is here to remind you that life's journey is best enjoyed one pebble at a time. Compact and full of charm, Pebble Dash is the perfect pocket-sized buddy for all your daily adventures.", + Images = "[\"images\\\\petrocks\\\\pebble_dash.png\"]", + Name = "Pebble Dash", + VariantTypes = "[\"Size\",\"Texture\"]" + }, + new + { + Id = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + Catchphrase = "Ready to rock and slate the day.", + Description = "Introducing Slate Mate, your steadfast and stylish rock friend! Crafted from sleek, smooth slate, Slate Mate is the epitome of cool and collected. With its flat, elegant surface and modern look, this rock is the perfect desk companion or decorative piece. Slate Mate is always there to offer unwavering support, whether you're tackling a tough task or relaxing after a long day. Its timeless appearance and dependable nature make Slate Mate a reliable friend for every moment. Embrace the stability and charm of Slate Mate, and let this solid companion help you slate the day!", + Images = "[\"images\\\\petrocks\\\\slate_mate.png\"]", + Name = "Slate Mate", + VariantTypes = "[\"Hardness\",\"Slateyness\"]" + }); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.VariantDto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("PetRockId") + .HasColumnType("TEXT"); + + b.Property("VariantTypeValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("PetRockId"); + + b.ToTable("Variants"); + + b.HasData( + new + { + Id = new Guid("1822b3fa-0b27-4bed-9d4b-617967e5619f"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Smooth\"}" + }, + new + { + Id = new Guid("572e0dbb-b2aa-4aac-a34f-770b7771cd6c"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Grainy\"}" + }, + new + { + Id = new Guid("8a778d4d-1b6d-4326-8694-ec2c578d9b57"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Jagged\"}" + }, + new + { + Id = new Guid("3f06dd60-3db9-42f3-8567-5143a3cd437b"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Smooth\"}" + }, + new + { + Id = new Guid("76984ca6-2571-4011-b136-9eaa1e7897f9"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Grainy\"}" + }, + new + { + Id = new Guid("037fa2cc-1189-4889-baca-3091e2cbadb6"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Jagged\"}" + }, + new + { + Id = new Guid("21f0d944-9ed1-424a-af96-944b6a056bcd"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Not very\"}" + }, + new + { + Id = new Guid("42f6cf5e-8816-4cc2-84f6-d9645e6c820c"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Moderately slatey\"}" + }, + new + { + Id = new Guid("0d3bf6d4-2760-4eb5-840d-3588f5b7bc54"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Extra slatey\"}" + }, + new + { + Id = new Guid("054d3143-f9d8-4b23-b1c4-3dcabfb8e68c"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Not very\"}" + }, + new + { + Id = new Guid("b2a75541-f22c-41b8-8662-b2fa17a37d4b"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Moderately slatey\"}" + }, + new + { + Id = new Guid("a5814287-e18a-486f-952e-02648c35d64e"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Extra slatey\"}" + }); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.VariantDto", b => + { + b.HasOne("Company.Api.PetRocks.Dtos.PetRockDto", "PetRock") + .WithMany("Variants") + .HasForeignKey("PetRockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Company.Api.PetRocks.Dtos.PriceDto", "Price", b1 => + { + b1.Property("VariantDtoId") + .HasColumnType("TEXT"); + + b1.Property("DealPriceGBP") + .HasColumnType("TEXT"); + + b1.Property("Details") + .HasColumnType("TEXT"); + + b1.Property("FullPriceGBP") + .HasColumnType("TEXT"); + + b1.HasKey("VariantDtoId"); + + b1.ToTable("Variants"); + + b1.WithOwner() + .HasForeignKey("VariantDtoId"); + + b1.HasData( + new + { + VariantDtoId = new Guid("1822b3fa-0b27-4bed-9d4b-617967e5619f"), + DealPriceGBP = 36.85m, + Details = "33% off while stocks last!", + FullPriceGBP = 55m + }, + new + { + VariantDtoId = new Guid("572e0dbb-b2aa-4aac-a34f-770b7771cd6c"), + DealPriceGBP = 41.54m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 62m + }, + new + { + VariantDtoId = new Guid("8a778d4d-1b6d-4326-8694-ec2c578d9b57"), + DealPriceGBP = 40.20m, + Details = "33% off today!", + FullPriceGBP = 60m + }, + new + { + VariantDtoId = new Guid("3f06dd60-3db9-42f3-8567-5143a3cd437b"), + DealPriceGBP = 46.23m, + Details = "33% off today!", + FullPriceGBP = 69m + }, + new + { + VariantDtoId = new Guid("76984ca6-2571-4011-b136-9eaa1e7897f9"), + DealPriceGBP = 57.62m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 86m + }, + new + { + VariantDtoId = new Guid("037fa2cc-1189-4889-baca-3091e2cbadb6"), + DealPriceGBP = 34.84m, + Details = "33% off while stocks last!", + FullPriceGBP = 52m + }, + new + { + VariantDtoId = new Guid("21f0d944-9ed1-424a-af96-944b6a056bcd"), + DealPriceGBP = 44.22m, + Details = "33% off today!", + FullPriceGBP = 66m + }, + new + { + VariantDtoId = new Guid("42f6cf5e-8816-4cc2-84f6-d9645e6c820c"), + DealPriceGBP = 28.81m, + Details = "33% off while stocks last!", + FullPriceGBP = 43m + }, + new + { + VariantDtoId = new Guid("0d3bf6d4-2760-4eb5-840d-3588f5b7bc54"), + DealPriceGBP = 8.71m, + Details = "33% off while stocks last!", + FullPriceGBP = 13m + }, + new + { + VariantDtoId = new Guid("054d3143-f9d8-4b23-b1c4-3dcabfb8e68c"), + DealPriceGBP = 26.80m, + Details = "33% off while stocks last!", + FullPriceGBP = 40m + }, + new + { + VariantDtoId = new Guid("b2a75541-f22c-41b8-8662-b2fa17a37d4b"), + DealPriceGBP = 8.71m, + Details = "33% off while stocks last!", + FullPriceGBP = 13m + }, + new + { + VariantDtoId = new Guid("a5814287-e18a-486f-952e-02648c35d64e"), + DealPriceGBP = 53.60m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 80m + }); + }); + + b.Navigation("PetRock"); + + b.Navigation("Price"); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.PetRockDto", b => + { + b.Navigation("Variants"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Api/Company.Api/Migrations/20240628134706_initialCreate.cs b/src/Api/Company.Api/Migrations/20240628134706_initialCreate.cs new file mode 100644 index 00000000..7b0e70ac --- /dev/null +++ b/src/Api/Company.Api/Migrations/20240628134706_initialCreate.cs @@ -0,0 +1,98 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Company.Api.Migrations +{ + /// + public partial class initialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "PetRocks", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: true), + Catchphrase = table.Column(type: "TEXT", nullable: true), + Description = table.Column(type: "TEXT", nullable: true), + VariantTypes = table.Column(type: "TEXT", nullable: false), + Images = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PetRocks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Variants", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + PetRockId = table.Column(type: "TEXT", nullable: false), + VariantTypeValues = table.Column(type: "TEXT", nullable: false), + Price_FullPriceGBP = table.Column(type: "TEXT", nullable: true), + Price_DealPriceGBP = table.Column(type: "TEXT", nullable: true), + Price_Details = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Variants", x => x.Id); + table.ForeignKey( + name: "FK_Variants_PetRocks_PetRockId", + column: x => x.PetRockId, + principalTable: "PetRocks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "PetRocks", + columns: new[] { "Id", "Catchphrase", "Description", "Images", "Name", "VariantTypes" }, + values: new object[,] + { + { new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "Ready to rock and slate the day.", "Introducing Slate Mate, your steadfast and stylish rock friend! Crafted from sleek, smooth slate, Slate Mate is the epitome of cool and collected. With its flat, elegant surface and modern look, this rock is the perfect desk companion or decorative piece. Slate Mate is always there to offer unwavering support, whether you're tackling a tough task or relaxing after a long day. Its timeless appearance and dependable nature make Slate Mate a reliable friend for every moment. Embrace the stability and charm of Slate Mate, and let this solid companion help you slate the day!", "[\"images\\\\petrocks\\\\slate_mate.png\"]", "Slate Mate", "[\"Hardness\",\"Slateyness\"]" }, + { new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "Rolling through life one pebble at a time.", "Meet Pebble Dash, your adventurous little companion! Small but full of energy, Pebble Dash is always ready to roll into new adventures. With a smooth surface and a perfectly rounded shape, this pebble loves to explore the world and bring joy wherever it goes. Whether it's a playful dash across the desk or a calming presence on your nightstand, Pebble Dash is here to remind you that life's journey is best enjoyed one pebble at a time. Compact and full of charm, Pebble Dash is the perfect pocket-sized buddy for all your daily adventures.", "[\"images\\\\petrocks\\\\pebble_dash.png\"]", "Pebble Dash", "[\"Size\",\"Texture\"]" } + }); + + migrationBuilder.InsertData( + table: "Variants", + columns: new[] { "Id", "Price_DealPriceGBP", "Price_Details", "Price_FullPriceGBP", "PetRockId", "VariantTypeValues" }, + values: new object[,] + { + { new Guid("037fa2cc-1189-4889-baca-3091e2cbadb6"), 34.84m, "33% off while stocks last!", 52m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Big\",\"Texture\":\"Jagged\"}" }, + { new Guid("054d3143-f9d8-4b23-b1c4-3dcabfb8e68c"), 26.80m, "33% off while stocks last!", 40m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Hard\",\"Slateyness\":\"Not very\"}" }, + { new Guid("0d3bf6d4-2760-4eb5-840d-3588f5b7bc54"), 8.71m, "33% off while stocks last!", 13m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Soft\",\"Slateyness\":\"Extra slatey\"}" }, + { new Guid("1822b3fa-0b27-4bed-9d4b-617967e5619f"), 36.85m, "33% off while stocks last!", 55m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Small\",\"Texture\":\"Smooth\"}" }, + { new Guid("21f0d944-9ed1-424a-af96-944b6a056bcd"), 44.22m, "33% off today!", 66m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Soft\",\"Slateyness\":\"Not very\"}" }, + { new Guid("3f06dd60-3db9-42f3-8567-5143a3cd437b"), 46.23m, "33% off today!", 69m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Big\",\"Texture\":\"Smooth\"}" }, + { new Guid("42f6cf5e-8816-4cc2-84f6-d9645e6c820c"), 28.81m, "33% off while stocks last!", 43m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Soft\",\"Slateyness\":\"Moderately slatey\"}" }, + { new Guid("572e0dbb-b2aa-4aac-a34f-770b7771cd6c"), 41.54m, "2/3 off for a limited time!", 62m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Small\",\"Texture\":\"Grainy\"}" }, + { new Guid("76984ca6-2571-4011-b136-9eaa1e7897f9"), 57.62m, "2/3 off for a limited time!", 86m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Big\",\"Texture\":\"Grainy\"}" }, + { new Guid("8a778d4d-1b6d-4326-8694-ec2c578d9b57"), 40.20m, "33% off today!", 60m, new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), "{\"Size\":\"Small\",\"Texture\":\"Jagged\"}" }, + { new Guid("a5814287-e18a-486f-952e-02648c35d64e"), 53.60m, "2/3 off for a limited time!", 80m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Hard\",\"Slateyness\":\"Extra slatey\"}" }, + { new Guid("b2a75541-f22c-41b8-8662-b2fa17a37d4b"), 8.71m, "33% off while stocks last!", 13m, new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), "{\"Hardness\":\"Hard\",\"Slateyness\":\"Moderately slatey\"}" } + }); + + migrationBuilder.CreateIndex( + name: "IX_Variants_PetRockId", + table: "Variants", + column: "PetRockId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Variants"); + + migrationBuilder.DropTable( + name: "PetRocks"); + } + } +} diff --git a/src/Api/Company.Api/Migrations/PetRockContextModelSnapshot.cs b/src/Api/Company.Api/Migrations/PetRockContextModelSnapshot.cs new file mode 100644 index 00000000..a520d3f4 --- /dev/null +++ b/src/Api/Company.Api/Migrations/PetRockContextModelSnapshot.cs @@ -0,0 +1,290 @@ +// +using System; +using Company.Api.PetRocks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Company.Api.Migrations +{ + [DbContext(typeof(PetRockContext))] + partial class PetRockContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.PetRockDto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Catchphrase") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Images") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("VariantTypes") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("PetRocks"); + + b.HasData( + new + { + Id = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + Catchphrase = "Rolling through life one pebble at a time.", + Description = "Meet Pebble Dash, your adventurous little companion! Small but full of energy, Pebble Dash is always ready to roll into new adventures. With a smooth surface and a perfectly rounded shape, this pebble loves to explore the world and bring joy wherever it goes. Whether it's a playful dash across the desk or a calming presence on your nightstand, Pebble Dash is here to remind you that life's journey is best enjoyed one pebble at a time. Compact and full of charm, Pebble Dash is the perfect pocket-sized buddy for all your daily adventures.", + Images = "[\"images\\\\petrocks\\\\pebble_dash.png\"]", + Name = "Pebble Dash", + VariantTypes = "[\"Size\",\"Texture\"]" + }, + new + { + Id = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + Catchphrase = "Ready to rock and slate the day.", + Description = "Introducing Slate Mate, your steadfast and stylish rock friend! Crafted from sleek, smooth slate, Slate Mate is the epitome of cool and collected. With its flat, elegant surface and modern look, this rock is the perfect desk companion or decorative piece. Slate Mate is always there to offer unwavering support, whether you're tackling a tough task or relaxing after a long day. Its timeless appearance and dependable nature make Slate Mate a reliable friend for every moment. Embrace the stability and charm of Slate Mate, and let this solid companion help you slate the day!", + Images = "[\"images\\\\petrocks\\\\slate_mate.png\"]", + Name = "Slate Mate", + VariantTypes = "[\"Hardness\",\"Slateyness\"]" + }); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.VariantDto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("PetRockId") + .HasColumnType("TEXT"); + + b.Property("VariantTypeValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("PetRockId"); + + b.ToTable("Variants"); + + b.HasData( + new + { + Id = new Guid("1822b3fa-0b27-4bed-9d4b-617967e5619f"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Smooth\"}" + }, + new + { + Id = new Guid("572e0dbb-b2aa-4aac-a34f-770b7771cd6c"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Grainy\"}" + }, + new + { + Id = new Guid("8a778d4d-1b6d-4326-8694-ec2c578d9b57"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Small\",\"Texture\":\"Jagged\"}" + }, + new + { + Id = new Guid("3f06dd60-3db9-42f3-8567-5143a3cd437b"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Smooth\"}" + }, + new + { + Id = new Guid("76984ca6-2571-4011-b136-9eaa1e7897f9"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Grainy\"}" + }, + new + { + Id = new Guid("037fa2cc-1189-4889-baca-3091e2cbadb6"), + PetRockId = new Guid("fe19a010-668b-441e-ae57-67cf63607c49"), + VariantTypeValues = "{\"Size\":\"Big\",\"Texture\":\"Jagged\"}" + }, + new + { + Id = new Guid("21f0d944-9ed1-424a-af96-944b6a056bcd"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Not very\"}" + }, + new + { + Id = new Guid("42f6cf5e-8816-4cc2-84f6-d9645e6c820c"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Moderately slatey\"}" + }, + new + { + Id = new Guid("0d3bf6d4-2760-4eb5-840d-3588f5b7bc54"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Soft\",\"Slateyness\":\"Extra slatey\"}" + }, + new + { + Id = new Guid("054d3143-f9d8-4b23-b1c4-3dcabfb8e68c"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Not very\"}" + }, + new + { + Id = new Guid("b2a75541-f22c-41b8-8662-b2fa17a37d4b"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Moderately slatey\"}" + }, + new + { + Id = new Guid("a5814287-e18a-486f-952e-02648c35d64e"), + PetRockId = new Guid("d5bf2e08-4324-44fb-8e50-a9b244b88947"), + VariantTypeValues = "{\"Hardness\":\"Hard\",\"Slateyness\":\"Extra slatey\"}" + }); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.VariantDto", b => + { + b.HasOne("Company.Api.PetRocks.Dtos.PetRockDto", "PetRock") + .WithMany("Variants") + .HasForeignKey("PetRockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Company.Api.PetRocks.Dtos.PriceDto", "Price", b1 => + { + b1.Property("VariantDtoId") + .HasColumnType("TEXT"); + + b1.Property("DealPriceGBP") + .HasColumnType("TEXT"); + + b1.Property("Details") + .HasColumnType("TEXT"); + + b1.Property("FullPriceGBP") + .HasColumnType("TEXT"); + + b1.HasKey("VariantDtoId"); + + b1.ToTable("Variants"); + + b1.WithOwner() + .HasForeignKey("VariantDtoId"); + + b1.HasData( + new + { + VariantDtoId = new Guid("1822b3fa-0b27-4bed-9d4b-617967e5619f"), + DealPriceGBP = 36.85m, + Details = "33% off while stocks last!", + FullPriceGBP = 55m + }, + new + { + VariantDtoId = new Guid("572e0dbb-b2aa-4aac-a34f-770b7771cd6c"), + DealPriceGBP = 41.54m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 62m + }, + new + { + VariantDtoId = new Guid("8a778d4d-1b6d-4326-8694-ec2c578d9b57"), + DealPriceGBP = 40.20m, + Details = "33% off today!", + FullPriceGBP = 60m + }, + new + { + VariantDtoId = new Guid("3f06dd60-3db9-42f3-8567-5143a3cd437b"), + DealPriceGBP = 46.23m, + Details = "33% off today!", + FullPriceGBP = 69m + }, + new + { + VariantDtoId = new Guid("76984ca6-2571-4011-b136-9eaa1e7897f9"), + DealPriceGBP = 57.62m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 86m + }, + new + { + VariantDtoId = new Guid("037fa2cc-1189-4889-baca-3091e2cbadb6"), + DealPriceGBP = 34.84m, + Details = "33% off while stocks last!", + FullPriceGBP = 52m + }, + new + { + VariantDtoId = new Guid("21f0d944-9ed1-424a-af96-944b6a056bcd"), + DealPriceGBP = 44.22m, + Details = "33% off today!", + FullPriceGBP = 66m + }, + new + { + VariantDtoId = new Guid("42f6cf5e-8816-4cc2-84f6-d9645e6c820c"), + DealPriceGBP = 28.81m, + Details = "33% off while stocks last!", + FullPriceGBP = 43m + }, + new + { + VariantDtoId = new Guid("0d3bf6d4-2760-4eb5-840d-3588f5b7bc54"), + DealPriceGBP = 8.71m, + Details = "33% off while stocks last!", + FullPriceGBP = 13m + }, + new + { + VariantDtoId = new Guid("054d3143-f9d8-4b23-b1c4-3dcabfb8e68c"), + DealPriceGBP = 26.80m, + Details = "33% off while stocks last!", + FullPriceGBP = 40m + }, + new + { + VariantDtoId = new Guid("b2a75541-f22c-41b8-8662-b2fa17a37d4b"), + DealPriceGBP = 8.71m, + Details = "33% off while stocks last!", + FullPriceGBP = 13m + }, + new + { + VariantDtoId = new Guid("a5814287-e18a-486f-952e-02648c35d64e"), + DealPriceGBP = 53.60m, + Details = "2/3 off for a limited time!", + FullPriceGBP = 80m + }); + }); + + b.Navigation("PetRock"); + + b.Navigation("Price"); + }); + + modelBuilder.Entity("Company.Api.PetRocks.Dtos.PetRockDto", b => + { + b.Navigation("Variants"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Api/Company.Api/Migrations/ProductContextModelSnapshot.cs b/src/Api/Company.Api/Migrations/ProductContextModelSnapshot.cs deleted file mode 100644 index 82110dcd..00000000 --- a/src/Api/Company.Api/Migrations/ProductContextModelSnapshot.cs +++ /dev/null @@ -1,290 +0,0 @@ -// -using System; -using Company.Api.Products; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Company.Api.Migrations -{ - [DbContext(typeof(ProductContext))] - partial class ProductContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.5"); - - modelBuilder.Entity("Company.Api.Products.Dtos.ProductDto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Headline") - .HasColumnType("TEXT"); - - b.Property("Images") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("VariantTypes") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Products"); - - b.HasData( - new - { - Id = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - Description = "Improve your well-being with Product One", - Headline = "A great product for great people", - Images = "[\"images\\\\products\\\\the_product_one.png\"]", - Name = "The Product One", - VariantTypes = "[\"Size\",\"Colour\"]" - }, - new - { - Id = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - Description = "Improve your mindfulness with Product Two", - Headline = "A brilliant product for brilliant people", - Images = "[\"images\\\\products\\\\the_product_two.png\"]", - Name = "The Product Two", - VariantTypes = "[\"Magnitude\",\"Emotion\"]" - }); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.VariantDto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("ProductId") - .HasColumnType("TEXT"); - - b.Property("VariantTypeValues") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Variants"); - - b.HasData( - new - { - Id = new Guid("5c863956-2891-4530-8bda-218b456e0b8b"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Green\"}" - }, - new - { - Id = new Guid("cb064427-54b4-47fb-a66b-95831bfa9b55"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Greener\"}" - }, - new - { - Id = new Guid("2901d199-c8ef-4200-9d3b-826d2256b5a1"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Small\",\"Colour\":\"Greenest\"}" - }, - new - { - Id = new Guid("86e66430-6260-49fc-aeb4-771caee74ce6"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Green\"}" - }, - new - { - Id = new Guid("0788c61e-9944-4e6c-8a3c-c33c1e89f1be"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Greener\"}" - }, - new - { - Id = new Guid("28b5525d-c920-44ba-9e36-990432589d83"), - ProductId = new Guid("c7192e81-0f5d-4c3e-aec5-d32c88aea039"), - VariantTypeValues = "{\"Size\":\"Big\",\"Colour\":\"Greenest\"}" - }, - new - { - Id = new Guid("2e72ffb3-4da2-4108-93f3-8f2128c99dc1"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Excited\"}" - }, - new - { - Id = new Guid("3facedd3-8fb4-4757-bbc5-af9fee02fadc"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Happy\"}" - }, - new - { - Id = new Guid("f87421b2-c1c9-4c6b-9e97-440763b5f735"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Small\",\"Emotion\":\"Flattered\"}" - }, - new - { - Id = new Guid("db9d3fea-4d12-4b9a-8e2a-0d5b53572708"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Excited\"}" - }, - new - { - Id = new Guid("5f3b4bef-3cbc-40bf-bca5-0e52f9d9bde8"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Happy\"}" - }, - new - { - Id = new Guid("51e94e79-392c-4753-886a-e751cff703a6"), - ProductId = new Guid("b3bc7c47-bb91-48f6-baa8-808652408abb"), - VariantTypeValues = "{\"Magnitude\":\"Vast\",\"Emotion\":\"Flattered\"}" - }); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.VariantDto", b => - { - b.HasOne("Company.Api.Products.Dtos.ProductDto", "Product") - .WithMany("Variants") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Company.Api.Products.Dtos.PriceDto", "Price", b1 => - { - b1.Property("VariantDtoId") - .HasColumnType("TEXT"); - - b1.Property("DealPriceGBP") - .HasColumnType("TEXT"); - - b1.Property("Details") - .HasColumnType("TEXT"); - - b1.Property("FullPriceGBP") - .HasColumnType("TEXT"); - - b1.HasKey("VariantDtoId"); - - b1.ToTable("Variants"); - - b1.WithOwner() - .HasForeignKey("VariantDtoId"); - - b1.HasData( - new - { - VariantDtoId = new Guid("5c863956-2891-4530-8bda-218b456e0b8b"), - DealPriceGBP = 64.99m, - Details = "33% off while stocks last!", - FullPriceGBP = 97m - }, - new - { - VariantDtoId = new Guid("cb064427-54b4-47fb-a66b-95831bfa9b55"), - DealPriceGBP = 54.94m, - Details = "33% off while stocks last!", - FullPriceGBP = 82m - }, - new - { - VariantDtoId = new Guid("2901d199-c8ef-4200-9d3b-826d2256b5a1"), - DealPriceGBP = 35.51m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 53m - }, - new - { - VariantDtoId = new Guid("86e66430-6260-49fc-aeb4-771caee74ce6"), - DealPriceGBP = 16.75m, - Details = "33% off while stocks last!", - FullPriceGBP = 25m - }, - new - { - VariantDtoId = new Guid("0788c61e-9944-4e6c-8a3c-c33c1e89f1be"), - DealPriceGBP = 16.08m, - Details = "33% off today!", - FullPriceGBP = 24m - }, - new - { - VariantDtoId = new Guid("28b5525d-c920-44ba-9e36-990432589d83"), - DealPriceGBP = 54.27m, - Details = "33% off today!", - FullPriceGBP = 81m - }, - new - { - VariantDtoId = new Guid("2e72ffb3-4da2-4108-93f3-8f2128c99dc1"), - DealPriceGBP = 6.70m, - Details = "33% off while stocks last!", - FullPriceGBP = 10m - }, - new - { - VariantDtoId = new Guid("3facedd3-8fb4-4757-bbc5-af9fee02fadc"), - DealPriceGBP = 3.35m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 5m - }, - new - { - VariantDtoId = new Guid("f87421b2-c1c9-4c6b-9e97-440763b5f735"), - DealPriceGBP = 66.33m, - Details = "33% off today!", - FullPriceGBP = 99m - }, - new - { - VariantDtoId = new Guid("db9d3fea-4d12-4b9a-8e2a-0d5b53572708"), - DealPriceGBP = 16.75m, - Details = "33% off while stocks last!", - FullPriceGBP = 25m - }, - new - { - VariantDtoId = new Guid("5f3b4bef-3cbc-40bf-bca5-0e52f9d9bde8"), - DealPriceGBP = 22.78m, - Details = "33% off while stocks last!", - FullPriceGBP = 34m - }, - new - { - VariantDtoId = new Guid("51e94e79-392c-4753-886a-e751cff703a6"), - DealPriceGBP = 49.58m, - Details = "2/3 off for a limited time!", - FullPriceGBP = 74m - }); - }); - - b.Navigation("Price"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("Company.Api.Products.Dtos.ProductDto", b => - { - b.Navigation("Variants"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Api/Company.Api/Products/Dtos/ProductDto.cs b/src/Api/Company.Api/PetRocks/Dtos/PetRockDto.cs similarity index 82% rename from src/Api/Company.Api/Products/Dtos/ProductDto.cs rename to src/Api/Company.Api/PetRocks/Dtos/PetRockDto.cs index 0b316da2..fcceb597 100644 --- a/src/Api/Company.Api/Products/Dtos/ProductDto.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/PetRockDto.cs @@ -3,15 +3,15 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; -public class ProductDto +public class PetRockDto { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } public string Name { get; set; } - public string Headline { get; set; } + public string Catchphrase { get; set; } public string Description { get; set; } public List VariantTypes { get; set; } public List Images { get; set; } diff --git a/src/Api/Company.Api/Products/Dtos/ProductDtoConfiguration.cs b/src/Api/Company.Api/PetRocks/Dtos/PetRockDtoConfiguration.cs similarity index 83% rename from src/Api/Company.Api/Products/Dtos/ProductDtoConfiguration.cs rename to src/Api/Company.Api/PetRocks/Dtos/PetRockDtoConfiguration.cs index 1cadc1f4..56ad1add 100644 --- a/src/Api/Company.Api/Products/Dtos/ProductDtoConfiguration.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/PetRockDtoConfiguration.cs @@ -3,11 +3,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; -public class ProductDtoConfiguration : IEntityTypeConfiguration +public class PetRockDtoConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.Property(e => e.VariantTypes) .IsRequired() diff --git a/src/Api/Company.Api/PetRocks/Dtos/PetRockDtoMapper.cs b/src/Api/Company.Api/PetRocks/Dtos/PetRockDtoMapper.cs new file mode 100644 index 00000000..b245fac2 --- /dev/null +++ b/src/Api/Company.Api/PetRocks/Dtos/PetRockDtoMapper.cs @@ -0,0 +1,27 @@ +using System; +using Company.Contract; + +namespace Company.Api.PetRocks.Dtos; + +public static class PetRockDtoMapper +{ + public static PetRockDto ToPetRockDto(this PetRock petRock) + => new PetRockDto + { + Id = Guid.Parse(petRock.Id), + Name = petRock.Name, + Catchphrase = petRock.Headline, + Description = petRock.Description, + VariantTypes = petRock.VariantTypes, + Images = petRock.Images + }; + + public static PetRock FromPetRockDto(this PetRockDto petRockDto) + => new PetRock( + petRockDto.Id.ToString(), + petRockDto.Name, + petRockDto.Catchphrase, + petRockDto.Description, + petRockDto.VariantTypes, + petRockDto.Images); +} diff --git a/src/Api/Company.Api/Products/Dtos/PriceDto.cs b/src/Api/Company.Api/PetRocks/Dtos/PriceDto.cs similarity index 70% rename from src/Api/Company.Api/Products/Dtos/PriceDto.cs rename to src/Api/Company.Api/PetRocks/Dtos/PriceDto.cs index ca3b832a..75feda11 100644 --- a/src/Api/Company.Api/Products/Dtos/PriceDto.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/PriceDto.cs @@ -1,7 +1,6 @@ using System; -using System.ComponentModel.DataAnnotations.Schema; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; public class PriceDto { diff --git a/src/Api/Company.Api/Products/Dtos/PriceDtoMapper.cs b/src/Api/Company.Api/PetRocks/Dtos/PriceDtoMapper.cs similarity index 92% rename from src/Api/Company.Api/Products/Dtos/PriceDtoMapper.cs rename to src/Api/Company.Api/PetRocks/Dtos/PriceDtoMapper.cs index 1cf13c20..5af0c7d9 100644 --- a/src/Api/Company.Api/Products/Dtos/PriceDtoMapper.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/PriceDtoMapper.cs @@ -1,6 +1,6 @@ using Company.Contract; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; public static class PriceDtoMapper { diff --git a/src/Api/Company.Api/Products/Dtos/VariantDto.cs b/src/Api/Company.Api/PetRocks/Dtos/VariantDto.cs similarity index 67% rename from src/Api/Company.Api/Products/Dtos/VariantDto.cs rename to src/Api/Company.Api/PetRocks/Dtos/VariantDto.cs index c6b08e18..771ff177 100644 --- a/src/Api/Company.Api/Products/Dtos/VariantDto.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/VariantDto.cs @@ -2,18 +2,17 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; public class VariantDto { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } - public Guid ProductId { get; set; } - [ForeignKey("ProductId")] - public ProductDto Product { get; set; } + public Guid PetRockId { get; set; } + [ForeignKey("PetRockId")] + public PetRockDto PetRock { get; set; } public Dictionary VariantTypeValues { get; set; } public PriceDto Price { get; set; } } diff --git a/src/Api/Company.Api/Products/Dtos/VariantDtoConfiguration.cs b/src/Api/Company.Api/PetRocks/Dtos/VariantDtoConfiguration.cs similarity index 95% rename from src/Api/Company.Api/Products/Dtos/VariantDtoConfiguration.cs rename to src/Api/Company.Api/PetRocks/Dtos/VariantDtoConfiguration.cs index ce9179fe..0f2e382e 100644 --- a/src/Api/Company.Api/Products/Dtos/VariantDtoConfiguration.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/VariantDtoConfiguration.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore; using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; public class VariantDtoConfiguration : IEntityTypeConfiguration { diff --git a/src/Api/Company.Api/Products/Dtos/VariantDtoMapper.cs b/src/Api/Company.Api/PetRocks/Dtos/VariantDtoMapper.cs similarity index 80% rename from src/Api/Company.Api/Products/Dtos/VariantDtoMapper.cs rename to src/Api/Company.Api/PetRocks/Dtos/VariantDtoMapper.cs index 0a8c3a87..ee0a9518 100644 --- a/src/Api/Company.Api/Products/Dtos/VariantDtoMapper.cs +++ b/src/Api/Company.Api/PetRocks/Dtos/VariantDtoMapper.cs @@ -1,7 +1,7 @@ using System; using Company.Contract; -namespace Company.Api.Products.Dtos; +namespace Company.Api.PetRocks.Dtos; public static class VariantDtoMapper { @@ -9,14 +9,14 @@ public static VariantDto ToVariantDto(this Variant variant) => new VariantDto { Id = Guid.Parse(variant.VariantId), - ProductId = Guid.Parse(variant.ProductId), + PetRockId = Guid.Parse(variant.PetRockId), VariantTypeValues = variant.VariantTypeValues, Price = variant.Price.ToPriceDto() }; public static Variant FromVariantDto(this VariantDto variantDto) => new Variant( - variantDto.ProductId.ToString(), + variantDto.PetRockId.ToString(), variantDto.Id.ToString(), variantDto.VariantTypeValues, variantDto.Price.FromPriceDto()); diff --git a/src/Api/Company.Api/Products/ProductContext.cs b/src/Api/Company.Api/PetRocks/PetRockContext.cs similarity index 55% rename from src/Api/Company.Api/Products/ProductContext.cs rename to src/Api/Company.Api/PetRocks/PetRockContext.cs index 3ceb8d9f..6df3551b 100644 --- a/src/Api/Company.Api/Products/ProductContext.cs +++ b/src/Api/Company.Api/PetRocks/PetRockContext.cs @@ -1,165 +1,164 @@ using System; using System.Collections.Generic; -using System.Linq; -using Company.Api.Products.Dtos; +using Company.Api.PetRocks.Dtos; using Microsoft.EntityFrameworkCore; -namespace Company.Api.Products; +namespace Company.Api.PetRocks; -public class ProductContext : DbContext +public class PetRockContext : DbContext { - public DbSet Products { get; set; } + public DbSet PetRocks { get; set; } public DbSet Variants { get; set; } - public ProductContext(DbContextOptions options) + public PetRockContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.ApplyConfiguration(new ProductDtoConfiguration()); + modelBuilder.ApplyConfiguration(new PetRockDtoConfiguration()); modelBuilder.ApplyConfiguration(new VariantDtoConfiguration()); - var product1 = new ProductDto + var petRock1 = new PetRockDto { Id = Guid.NewGuid(), - Name = "The Product One", - Headline = "A great product for great people", - Description = "Improve your well-being with Product One", - VariantTypes = new List { "Size", "Colour" }, - Images = new List { @"images\products\the_product_one.png" } + Name = "Pebble Dash", + Catchphrase = "Rolling through life one pebble at a time.", + Description = "Meet Pebble Dash, your adventurous little companion! Small but full of energy, Pebble Dash is always ready to roll into new adventures. With a smooth surface and a perfectly rounded shape, this pebble loves to explore the world and bring joy wherever it goes. Whether it's a playful dash across the desk or a calming presence on your nightstand, Pebble Dash is here to remind you that life's journey is best enjoyed one pebble at a time. Compact and full of charm, Pebble Dash is the perfect pocket-sized buddy for all your daily adventures.", + VariantTypes = ["Size", "Texture"], + Images = [@"images\petrocks\pebble_dash.png"] }; - var product2 = new ProductDto + var petRock2 = new PetRockDto { Id = Guid.NewGuid(), - Name = "The Product Two", - Headline = "A brilliant product for brilliant people", - Description = "Improve your mindfulness with Product Two", - VariantTypes = new List { "Magnitude", "Emotion" }, - Images = new List { @"images\products\the_product_two.png" } + Name = "Slate Mate", + Catchphrase = "Ready to rock and slate the day.", + Description = "Introducing Slate Mate, your steadfast and stylish rock friend! Crafted from sleek, smooth slate, Slate Mate is the epitome of cool and collected. With its flat, elegant surface and modern look, this rock is the perfect desk companion or decorative piece. Slate Mate is always there to offer unwavering support, whether you're tackling a tough task or relaxing after a long day. Its timeless appearance and dependable nature make Slate Mate a reliable friend for every moment. Embrace the stability and charm of Slate Mate, and let this solid companion help you slate the day!", + VariantTypes = ["Hardness", "Slateyness"], + Images = [@"images\petrocks\slate_mate.png"] }; - modelBuilder.Entity().HasData(product1, product2); + modelBuilder.Entity().HasData(petRock1, petRock2); var rand = new Random(); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Small" }, - { "Colour", "Green" }, + { "Texture", "Smooth" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Small" }, - { "Colour", "Greener" }, + { "Texture", "Grainy" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Small" }, - { "Colour", "Greenest" }, + { "Texture", "Jagged" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Big" }, - { "Colour", "Green" }, + { "Texture", "Smooth" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Big" }, - { "Colour", "Greener" }, + { "Texture", "Grainy" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product1.Id, + PetRockId = petRock1.Id, VariantTypeValues = new Dictionary { { "Size", "Big" }, - { "Colour", "Greenest" }, + { "Texture", "Jagged" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Small" }, - { "Emotion", "Excited" }, + { "Hardness", "Soft" }, + { "Slateyness", "Not very" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Small" }, - { "Emotion", "Happy" }, + { "Hardness", "Soft" }, + { "Slateyness", "Moderately slatey" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Small" }, - { "Emotion", "Flattered" }, + { "Hardness", "Soft" }, + { "Slateyness", "Extra slatey" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Vast" }, - { "Emotion", "Excited" }, + { "Hardness", "Hard" }, + { "Slateyness", "Not very" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Vast" }, - { "Emotion", "Happy" }, + { "Hardness", "Hard" }, + { "Slateyness", "Moderately slatey" }, }, }); AddWithRandomPrice(modelBuilder, rand, new VariantDto { Id = Guid.NewGuid(), - ProductId = product2.Id, + PetRockId = petRock2.Id, VariantTypeValues = new Dictionary { - { "Magnitude", "Vast" }, - { "Emotion", "Flattered" }, + { "Hardness", "Hard" }, + { "Slateyness", "Extra slatey" }, }, }); } diff --git a/src/Api/Company.Api/PetRocks/PetRocksController.cs b/src/Api/Company.Api/PetRocks/PetRocksController.cs new file mode 100644 index 00000000..faa7bd18 --- /dev/null +++ b/src/Api/Company.Api/PetRocks/PetRocksController.cs @@ -0,0 +1,58 @@ +using System; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Company.Api.PetRocks.Dtos; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace Company.Api.PetRocks; + +[ApiController] +[Route("petrocks")] +public class PetRocksController : ControllerBase +{ + private static readonly ActivitySource MyActivitySource = new(nameof(PetRocksController), "1.0.0"); + + private readonly ILogger _logger; + private readonly PetRockContext _context; + + public PetRocksController(ILogger logger, PetRockContext context) + { + _logger = logger; + _context = context; + } + + [HttpGet("")] + public async Task GetPetRocks() { + var petRockDtos = _context.PetRocks; + using var activity = MyActivitySource.StartActivity("GetPetRocksActivity"); + var petRocks = await petRockDtos.Select(p => p.FromPetRockDto()).ToListAsync(); + return Ok(petRocks); + } + + [HttpGet("{petRockId}")] + public async Task GetPetRockById(Guid petRockId) + { + var petRockDto = await _context.PetRocks.FindAsync(petRockId); + var petRock = petRockDto.FromPetRockDto(); + return Ok(petRock); + } + + [HttpGet("{petRockId}/variants")] + public async Task GetPetRockVariants(Guid petRockId) + { + var variantDtos = await _context.Variants.Where(v => v.PetRockId == petRockId).ToListAsync(); + var variants = variantDtos.Select(v => v.FromVariantDto()); + return Ok(variants); + } + + [HttpGet("{petRockId}/variants/{variantId}")] + public async Task GetPetRockVariantById(Guid variantId) + { + var variantDto = await _context.Variants.FindAsync(variantId); + var variant = variantDto.FromVariantDto(); + return Ok(variant); + } +} diff --git a/src/Api/Company.Api/Products/Dtos/ProductDtoMapper.cs b/src/Api/Company.Api/Products/Dtos/ProductDtoMapper.cs deleted file mode 100644 index f74ba6c0..00000000 --- a/src/Api/Company.Api/Products/Dtos/ProductDtoMapper.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Company.Contract; - -namespace Company.Api.Products.Dtos; - -public static class ProductDtoMapper -{ - public static ProductDto ToProductDto(this Product product) - => new ProductDto - { - Id = Guid.Parse(product.Id), - Name = product.Name, - Headline = product.Headline, - Description = product.Description, - VariantTypes = product.VariantTypes, - Images = product.Images - }; - - public static Product FromProductDto(this ProductDto productDto) - => new Product( - productDto.Id.ToString(), - productDto.Name, - productDto.Headline, - productDto.Description, - productDto.VariantTypes, - productDto.Images); -} diff --git a/src/Api/Company.Api/Products/ProductsController.cs b/src/Api/Company.Api/Products/ProductsController.cs deleted file mode 100644 index 159b93b7..00000000 --- a/src/Api/Company.Api/Products/ProductsController.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Company.Api.Products.Dtos; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - -namespace Company.Api.Products; - -[ApiController] -[Route("products")] -public class ProductsController : ControllerBase -{ - private static readonly ActivitySource MyActivitySource = new(nameof(ProductsController), "1.0.0"); - - private readonly ILogger _logger; - private readonly ProductContext _context; - - public ProductsController(ILogger logger, ProductContext context) - { - _logger = logger; - _context = context; - } - - [HttpGet("")] - public async Task GetProducts() { - var productDtos = _context.Products; - using var activity = MyActivitySource.StartActivity("GetProductsActivity"); - var products = await productDtos.Select(p => p.FromProductDto()).ToListAsync(); - return Ok(products); - } - - [HttpGet("{productId}")] - public async Task GetProductById(Guid productId) - { - var productDto = await _context.Products.FindAsync(productId); - var product = productDto.FromProductDto(); - return Ok(product); - } - - [HttpGet("{productId}/variants")] - public async Task GetProductVariants(Guid productId) - { - var variantDtos = await _context.Variants.Where(v => v.ProductId == productId).ToListAsync(); - var variants = variantDtos.Select(v => v.FromVariantDto()); - return Ok(variants); - } - - [HttpGet("{productId}/variants/{variantId}")] - public async Task GetProductVariantById(Guid variantId) - { - var variantDto = await _context.Variants.FindAsync(variantId); - var variant = variantDto.FromVariantDto(); - return Ok(variant); - } -} diff --git a/src/Api/Company.Api/Program.cs b/src/Api/Company.Api/Program.cs index 477e9879..034f0f3f 100644 --- a/src/Api/Company.Api/Program.cs +++ b/src/Api/Company.Api/Program.cs @@ -1,6 +1,6 @@ using System; using System.Reflection; -using Company.Api.Products; +using Company.Api.PetRocks; using Microsoft.AspNetCore.Builder; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; @@ -46,7 +46,7 @@ .AddAspNetCoreInstrumentation() .AddRuntimeInstrumentation()) .WithTracing(tracerProviderBuilder => tracerProviderBuilder - .AddSource(serviceName, nameof(ProductsController)) + .AddSource(serviceName, nameof(PetRocksController)) .SetResourceBuilder(appResourceBuilder) .AddAspNetCoreInstrumentation() .AddEntityFrameworkCoreInstrumentation()); @@ -72,7 +72,7 @@ { DataSource = "CompanyApi.db", Mode = SqliteOpenMode.ReadWriteCreate, }; -builder.Services.AddDbContext(options => +builder.Services.AddDbContext(options => options.UseSqlite(sqlLiteConnectionStringBuilder.ConnectionString)); var host = builder.Build(); @@ -95,7 +95,7 @@ using (var scope = host.Services.CreateScope()) { - var db = scope.ServiceProvider.GetRequiredService(); + var db = scope.ServiceProvider.GetRequiredService(); db.Database.Migrate(); } diff --git a/src/Shared/Company.Contract/Product.cs b/src/Shared/Company.Contract/PetRock.cs similarity index 87% rename from src/Shared/Company.Contract/Product.cs rename to src/Shared/Company.Contract/PetRock.cs index faac1a94..56dbc552 100644 --- a/src/Shared/Company.Contract/Product.cs +++ b/src/Shared/Company.Contract/PetRock.cs @@ -1,6 +1,6 @@ namespace Company.Contract; -public record Product( +public record PetRock( string Id, string Name, string Headline, diff --git a/src/Shared/Company.Contract/Variant.cs b/src/Shared/Company.Contract/Variant.cs index af15246d..8afab197 100644 --- a/src/Shared/Company.Contract/Variant.cs +++ b/src/Shared/Company.Contract/Variant.cs @@ -2,7 +2,7 @@ namespace Company.Contract; public record Variant( - string ProductId, + string PetRockId, string VariantId, Dictionary VariantTypeValues, Price Price diff --git a/src/Website/Company.Website.Components/HoverCard.razor b/src/Website/Company.Website.Components/HoverCard.razor index 3d399e3a..2f9f1941 100644 --- a/src/Website/Company.Website.Components/HoverCard.razor +++ b/src/Website/Company.Website.Components/HoverCard.razor @@ -2,13 +2,13 @@ Card image
-
@Title
+

@Title

@Headline
+ Adopt me!

@Description

- Browse
diff --git a/src/Website/Company.Website.Components/HoverCard.razor.css b/src/Website/Company.Website.Components/HoverCard.razor.css index 20c48b12..d6d0e750 100644 --- a/src/Website/Company.Website.Components/HoverCard.razor.css +++ b/src/Website/Company.Website.Components/HoverCard.razor.css @@ -5,31 +5,35 @@ text-align: center; } - .hover-card .card-img-top { - max-height: 40vh; - object-fit: cover - } +.hover-card .card-img-top { + max-height: 40vh; + object-fit: cover +} - .hover-card .card-img-overlay { - text-shadow: 0 0 4px rgba(0,0,0,0.4); - } +.hover-card .card-img-overlay { + text-shadow: 0 0 4px rgba(0, 0, 0, 0.4); +} - .hover-card .card-img-overlay-hover { - position: absolute; - bottom: 0; - left: 0; - right: 0; - background-color: #121212; - width: 100%; - height: 0; - transition: .5s ease; - } +.hover-card .card-img-overlay-hover { + position: absolute; + bottom: 0; + left: 0; + right: 0; + background-color: var(--slate-blue); + width: 100%; + height: 0; + transition: .5s ease; + overflow-y: auto; +} - .hover-card:hover .card-img-overlay-hover { - height: 100%; - } +.hover-card:hover .card-img-overlay-hover { + height: 100%; +} -.browse-button { - color: #121212; +.adopt-button { background-color: white } + +.card-text { + padding-top: 20px; +} diff --git a/src/Website/Company.Website/App.razor b/src/Website/Company.Website/App.razor index c5045b70..7d4c49f8 100644 --- a/src/Website/Company.Website/App.razor +++ b/src/Website/Company.Website/App.razor @@ -6,8 +6,8 @@
-

Company Website

-

Loading the requested page...

+

Rock Pals

+

Finding your perfect pebble...

diff --git a/src/Website/Company.Website/Home/Index.razor b/src/Website/Company.Website/Home/Index.razor index cdd978b8..acfd369b 100644 --- a/src/Website/Company.Website/Home/Index.razor +++ b/src/Website/Company.Website/Home/Index.razor @@ -1,25 +1,26 @@ @page "/" @using Company.Contract; +@using Company.Website.PetRocks -@inject ProductService _productService +@inject PetRockService PetRockService
- @if (products != null) + @if (petRocks != null) {
- @foreach (var product in products) + @foreach (var petRock in petRocks) { - + }
}
@code { - private List products; + private List petRocks; protected override async Task OnInitializedAsync() { - products = await _productService.GetProducts(); + petRocks = await PetRockService.GetPetRocks(); } } diff --git a/src/Website/Company.Website/Products/CurrencyService.cs b/src/Website/Company.Website/PetRocks/CurrencyService.cs similarity index 89% rename from src/Website/Company.Website/Products/CurrencyService.cs rename to src/Website/Company.Website/PetRocks/CurrencyService.cs index b9c6fe6b..2f95caa7 100644 --- a/src/Website/Company.Website/Products/CurrencyService.cs +++ b/src/Website/Company.Website/PetRocks/CurrencyService.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Company.Website.Products; +namespace Company.Website.PetRocks; public class CurrencyService { diff --git a/src/Website/Company.Website/Products/Index.razor b/src/Website/Company.Website/PetRocks/Index.razor similarity index 71% rename from src/Website/Company.Website/Products/Index.razor rename to src/Website/Company.Website/PetRocks/Index.razor index 27d3314c..a78930cc 100644 --- a/src/Website/Company.Website/Products/Index.razor +++ b/src/Website/Company.Website/PetRocks/Index.razor @@ -1,6 +1,6 @@ -@page "/products/{ProductId}" +@page "/petrocks/{PetRockId}" -@inject ProductService _productService; +@inject PetRockService PetRockService; @inject CurrencyService _currencyService @if (_ready) @@ -9,12 +9,12 @@
-
- image +
+ image
-

@_product.Name

+

@_petRock.Name


@if (_selectedVariant.Price.FullPriceGBP > _selectedVariant.Price.DealPriceGBP) @@ -41,18 +41,18 @@
@GetFormattedAmount(_selectedVariant.Price.DealPriceGBP)
}

@_selectedVariant.Price.Details

- - - -
@_product.Headline
-

@_product.Description

+
+ +
+
@_petRock.Headline
+

@_petRock.Description

@GetFormattedAmount(_selectedVariant.Price.DealPriceGBP)
- +
@@ -64,9 +64,9 @@ @code { [Parameter] - public string ProductId { get; set; } + public string PetRockId { get; set; } - private Product _product; + private PetRock _petRock; private List _variants; private Variant _selectedVariant; private string _currencyCode; @@ -76,8 +76,8 @@ protected override async Task OnParametersSetAsync() { - _product = await _productService.GetProductById(ProductId); - _variants = await _productService.GetProductVariants(ProductId); + _petRock = await PetRockService.GetPetRockById(PetRockId); + _variants = await PetRockService.GetPetRockVariants(PetRockId); _selectedVariant = _variants.FirstOrDefault(); _currencySymbol = _currencyService.GetCurrencyCharacter("GBP"); _ready = true; @@ -86,13 +86,13 @@ private string GetFormattedAmount(decimal amount) => $"{_currencySymbol}{amount:0.00} {_currencyCode}"; - private void OnNewProductVariantSelected(Variant selectedVariant) + private void OnNewPetRockVariantSelected(Variant selectedVariant) { _selectedVariant = selectedVariant; StateHasChanged(); } - private void OnProductAddedToBasket() + private void OnPetRockAddedToBasket() { _addedToBasket = true; StateHasChanged(); diff --git a/src/Website/Company.Website/PetRocks/PetRockCard.razor b/src/Website/Company.Website/PetRocks/PetRockCard.razor new file mode 100644 index 00000000..93ed5221 --- /dev/null +++ b/src/Website/Company.Website/PetRocks/PetRockCard.razor @@ -0,0 +1,14 @@ +@if (PetRock != null) +{ + + +} + +@code { + [Parameter] + public PetRock PetRock { get; set; } +} diff --git a/src/Website/Company.Website/Products/ProductCard.razor.css b/src/Website/Company.Website/PetRocks/PetRockCard.razor.css similarity index 100% rename from src/Website/Company.Website/Products/ProductCard.razor.css rename to src/Website/Company.Website/PetRocks/PetRockCard.razor.css diff --git a/src/Website/Company.Website/PetRocks/PetRockService.cs b/src/Website/Company.Website/PetRocks/PetRockService.cs new file mode 100644 index 00000000..977de1a4 --- /dev/null +++ b/src/Website/Company.Website/PetRocks/PetRockService.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Json; +using System.Threading.Tasks; +using Company.Contract; + +namespace Company.Website.PetRocks; + +public class PetRockService +{ + private readonly HttpClient _httpClient; + + public PetRockService(HttpClient httpClient) => _httpClient = httpClient; + + public Task> GetPetRocks() => _httpClient.GetFromJsonAsync>("petrocks"); + + public Task GetPetRockById(string petRockId) => _httpClient.GetFromJsonAsync($"petrocks/{petRockId}"); + + public Task> GetPetRockVariants(string petRockId) => _httpClient.GetFromJsonAsync>($"petrocks/{petRockId}/variants"); + + public Task GetPetRockVariantById(string petRockId, string variantId) => _httpClient.GetFromJsonAsync($"petrocks/{petRockId}/variants/{variantId}"); +} diff --git a/src/Website/Company.Website/Products/PricingLabel.razor b/src/Website/Company.Website/PetRocks/PricingLabel.razor similarity index 75% rename from src/Website/Company.Website/Products/PricingLabel.razor rename to src/Website/Company.Website/PetRocks/PricingLabel.razor index f6f067cd..15d5d79c 100644 --- a/src/Website/Company.Website/Products/PricingLabel.razor +++ b/src/Website/Company.Website/PetRocks/PricingLabel.razor @@ -1,4 +1,4 @@ -@inject ProductService _productService +@inject PetRockService PetRockService @inject CurrencyService _currencyService @if (Price != null) @@ -12,9 +12,9 @@ @code { [Parameter] - public string ProductId { get; set; } + public string PetRockId { get; set; } [Parameter] - public string ProductVariantId { get; set; } + public string PetRockVariantId { get; set; } [Parameter] public string CurrencyCode { get; set; } @@ -25,7 +25,7 @@ { CurrencySymbol = _currencyService.GetCurrencyCharacter(CurrencyCode); - Price = (await _productService.GetProductVariantById(ProductId, ProductVariantId)).Price; + Price = (await PetRockService.GetPetRockVariantById(PetRockId, PetRockVariantId)).Price; } private string GetFormattedAmount(decimal amount) => $"{CurrencySymbol}{amount:0.00} {CurrencyCode}"; diff --git a/src/Website/Company.Website/Products/PricingLabel.razor.css b/src/Website/Company.Website/PetRocks/PricingLabel.razor.css similarity index 100% rename from src/Website/Company.Website/Products/PricingLabel.razor.css rename to src/Website/Company.Website/PetRocks/PricingLabel.razor.css diff --git a/src/Website/Company.Website/Products/PricingTotal.razor b/src/Website/Company.Website/PetRocks/PricingTotal.razor similarity index 65% rename from src/Website/Company.Website/Products/PricingTotal.razor rename to src/Website/Company.Website/PetRocks/PricingTotal.razor index 03f1f2d5..188ad432 100644 --- a/src/Website/Company.Website/Products/PricingTotal.razor +++ b/src/Website/Company.Website/PetRocks/PricingTotal.razor @@ -1,4 +1,4 @@ -@inject ProductService _productService +@inject PetRockService PetRockService @inject CurrencyService _currencyService

@@ -14,7 +14,7 @@ [Parameter] public string TotalType { get; set; } [Parameter] - public List<(string productId, string productVarientId, int quantity)> ProductVariantIdAndQuantities { get; set; } + public List<(string petRockId, string petRockVarientId, int quantity)> PetRockVariantIdAndQuantities { get; set; } [Parameter] public string CurrencyCode { get; set; } @@ -26,18 +26,18 @@ { CurrencySymbol = _currencyService.GetCurrencyCharacter(CurrencyCode); - if (ProductVariantIdAndQuantities == null) + if (PetRockVariantIdAndQuantities == null) { return; } var fullTotalPrice = 0m; var dealTotalPrice = 0m; - foreach (var productVariantIdAndQuantity in ProductVariantIdAndQuantities) + foreach (var petRockVariantIdAndQuantity in PetRockVariantIdAndQuantities) { - var price = (await _productService.GetProductVariantById(productVariantIdAndQuantity.productId, productVariantIdAndQuantity.productVarientId)).Price; - fullTotalPrice += price.FullPriceGBP * productVariantIdAndQuantity.quantity; - dealTotalPrice += price.DealPriceGBP * productVariantIdAndQuantity.Item3; + var price = (await PetRockService.GetPetRockVariantById(petRockVariantIdAndQuantity.petRockId, petRockVariantIdAndQuantity.petRockVarientId)).Price; + fullTotalPrice += price.FullPriceGBP * petRockVariantIdAndQuantity.quantity; + dealTotalPrice += price.DealPriceGBP * petRockVariantIdAndQuantity.Item3; } FullTotalPrice = fullTotalPrice; DealTotalPrice = dealTotalPrice; diff --git a/src/Website/Company.Website/Products/PricingTotal.razor.css b/src/Website/Company.Website/PetRocks/PricingTotal.razor.css similarity index 100% rename from src/Website/Company.Website/Products/PricingTotal.razor.css rename to src/Website/Company.Website/PetRocks/PricingTotal.razor.css diff --git a/src/Website/Company.Website/Products/VariantSelector.razor b/src/Website/Company.Website/PetRocks/VariantSelector.razor similarity index 85% rename from src/Website/Company.Website/Products/VariantSelector.razor rename to src/Website/Company.Website/PetRocks/VariantSelector.razor index 4c214535..6de7b7cf 100644 --- a/src/Website/Company.Website/Products/VariantSelector.razor +++ b/src/Website/Company.Website/PetRocks/VariantSelector.razor @@ -1,8 +1,8 @@ -@inject ProductService _productService +@inject PetRockService PetRockService @foreach (var availableVariantType in _availableVariantTypes) { -

@availableVariantType.Key
+

@availableVariantType.Key