From efc70084c32da04d0a8185d17853b477e5b87ef9 Mon Sep 17 00:00:00 2001 From: "Tizian.Breuch" Date: Wed, 26 Nov 2025 09:56:05 +0100 Subject: [PATCH] shipping method weight --- Webshop.Api/Program.cs | 2 +- .../DTOs/Shipping/ShippingMethodDto.cs | 10 +- .../Admin/AdminShippingMethodService.cs | 25 +- Webshop.Domain/Entities/ShippingMethod.cs | 58 +- ...126085553_shippingmethodWeight.Designer.cs | 1372 +++++++++++++++++ .../20251126085553_shippingmethodWeight.cs | 40 + .../ApplicationDbContextModelSnapshot.cs | 6 + 7 files changed, 1472 insertions(+), 41 deletions(-) create mode 100644 Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.Designer.cs create mode 100644 Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.cs diff --git a/Webshop.Api/Program.cs b/Webshop.Api/Program.cs index 849968b..eaa60d7 100644 --- a/Webshop.Api/Program.cs +++ b/Webshop.Api/Program.cs @@ -211,7 +211,7 @@ builder.Services.AddSwaggerGen(c => c.SchemaFilter(); c.OperationFilter(); c.OperationFilter(); - c.OperationFilter(); + //c.OperationFilter(); c.OperationFilter(); c.OperationFilter(); c.OperationFilter(); diff --git a/Webshop.Application/DTOs/Shipping/ShippingMethodDto.cs b/Webshop.Application/DTOs/Shipping/ShippingMethodDto.cs index 822a93a..1d6dbd2 100644 --- a/Webshop.Application/DTOs/Shipping/ShippingMethodDto.cs +++ b/Webshop.Application/DTOs/Shipping/ShippingMethodDto.cs @@ -1,8 +1,4 @@ -// Auto-generiert von CreateWebshopFiles.ps1 using System; -using System.Collections.Generic; -using System.Threading.Tasks; - namespace Webshop.Application.DTOs.Shipping { @@ -15,5 +11,9 @@ namespace Webshop.Application.DTOs.Shipping public bool IsActive { get; set; } public int MinDeliveryDays { get; set; } public int MaxDeliveryDays { get; set; } + + // NEU: Gewichtsgrenzen für diese Methode + public decimal MinWeight { get; set; } + public decimal MaxWeight { get; set; } } -} +} \ No newline at end of file diff --git a/Webshop.Application/Services/Admin/AdminShippingMethodService.cs b/Webshop.Application/Services/Admin/AdminShippingMethodService.cs index 7281303..d2898ce 100644 --- a/Webshop.Application/Services/Admin/AdminShippingMethodService.cs +++ b/Webshop.Application/Services/Admin/AdminShippingMethodService.cs @@ -1,14 +1,13 @@ -// src/Webshop.Application/Services/Admin/AdminShippingMethodService.cs -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; // Hinzufügen für .AnyAsync +using Microsoft.EntityFrameworkCore; using Webshop.Application; using Webshop.Application.DTOs.Shipping; using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; -using Webshop.Infrastructure.Data; // Hinzufügen für DbContext +using Webshop.Infrastructure.Data; namespace Webshop.Application.Services.Admin { @@ -55,14 +54,15 @@ namespace Webshop.Application.Services.Admin Description = shippingMethodDto.Description, BaseCost = shippingMethodDto.Cost, IsActive = shippingMethodDto.IsActive, - // +++ KORREKTUR +++ MinDeliveryDays = shippingMethodDto.MinDeliveryDays, - MaxDeliveryDays = shippingMethodDto.MaxDeliveryDays + MaxDeliveryDays = shippingMethodDto.MaxDeliveryDays, + // NEU: Gewichte mappen + MinWeight = shippingMethodDto.MinWeight, + MaxWeight = shippingMethodDto.MaxWeight }; await _shippingMethodRepository.AddAsync(newMethod); - // Verwende MapToDto, um eine konsistente Antwort zu gewährleisten return ServiceResult.Ok(MapToDto(newMethod)); } @@ -75,6 +75,7 @@ namespace Webshop.Application.Services.Admin } var allMethods = await _shippingMethodRepository.GetAllAsync(); + // Prüfen, ob der Name von einer ANDEREN Methode bereits verwendet wird if (allMethods.Any(sm => sm.Name.Equals(shippingMethodDto.Name, StringComparison.OrdinalIgnoreCase) && sm.Id != shippingMethodDto.Id)) { return ServiceResult.Fail(ServiceResultType.Conflict, $"Eine andere Versandmethode mit dem Namen '{shippingMethodDto.Name}' existiert bereits."); @@ -84,9 +85,11 @@ namespace Webshop.Application.Services.Admin existingMethod.Description = shippingMethodDto.Description; existingMethod.BaseCost = shippingMethodDto.Cost; existingMethod.IsActive = shippingMethodDto.IsActive; - // +++ KORREKTUR +++ existingMethod.MinDeliveryDays = shippingMethodDto.MinDeliveryDays; existingMethod.MaxDeliveryDays = shippingMethodDto.MaxDeliveryDays; + // NEU: Gewichte aktualisieren + existingMethod.MinWeight = shippingMethodDto.MinWeight; + existingMethod.MaxWeight = shippingMethodDto.MaxWeight; await _shippingMethodRepository.UpdateAsync(existingMethod); return ServiceResult.Ok(); @@ -119,9 +122,11 @@ namespace Webshop.Application.Services.Admin Description = sm.Description, Cost = sm.BaseCost, IsActive = sm.IsActive, - // +++ KORREKTUR +++ MinDeliveryDays = sm.MinDeliveryDays, - MaxDeliveryDays = sm.MaxDeliveryDays + MaxDeliveryDays = sm.MaxDeliveryDays, + // NEU: Gewichte ins DTO übertragen + MinWeight = sm.MinWeight, + MaxWeight = sm.MaxWeight }; } } diff --git a/Webshop.Domain/Entities/ShippingMethod.cs b/Webshop.Domain/Entities/ShippingMethod.cs index fe4c767..0e346ed 100644 --- a/Webshop.Domain/Entities/ShippingMethod.cs +++ b/Webshop.Domain/Entities/ShippingMethod.cs @@ -1,38 +1,46 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Webshop.Domain.Entities; - -/// -/// Konfigurierbare Versandoptionen für den Checkout. -/// -public class ShippingMethod +namespace Webshop.Domain.Entities { - [Key] - public Guid Id { get; set; } + /// + /// Konfigurierbare Versandoptionen für den Checkout. + /// + public class ShippingMethod + { + [Key] + public Guid Id { get; set; } - [Required] - [MaxLength(100)] - public string Name { get; set; } + [Required] + [MaxLength(100)] + public string Name { get; set; } = string.Empty; - [MaxLength(500)] - public string? Description { get; set; } + [MaxLength(500)] + public string? Description { get; set; } - // Precision wird via Fluent API konfiguriert - [Required] - public decimal BaseCost { get; set; } + // Grundkosten der Versandmethode + [Required] + public decimal BaseCost { get; set; } - public decimal? MinimumOrderAmount { get; set; } + // Optional: Mindestbestellwert (für kostenlosen Versand etc.) + public decimal? MinimumOrderAmount { get; set; } - [Required] - public bool IsActive { get; set; } + [Required] + public bool IsActive { get; set; } - [MaxLength(100)] - public string? EstimatedDeliveryTime { get; set; } + [MaxLength(100)] + public string? EstimatedDeliveryTime { get; set; } - [Required] - public bool RequiresTracking { get; set; } + [Required] + public bool RequiresTracking { get; set; } - public int MinDeliveryDays { get; set; } - public int MaxDeliveryDays { get; set; } + public int MinDeliveryDays { get; set; } + public int MaxDeliveryDays { get; set; } + + // NEU: Gewichtsbasierte Berechnung + // Einheit: kg (oder die Standardeinheit deines Shops) + public decimal MinWeight { get; set; } = 0; + + public decimal MaxWeight { get; set; } = 0; + } } \ No newline at end of file diff --git a/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.Designer.cs b/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.Designer.cs new file mode 100644 index 0000000..231b67f --- /dev/null +++ b/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.Designer.cs @@ -0,0 +1,1372 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Webshop.Infrastructure.Data; + +#nullable disable + +namespace Webshop.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251126085553_shippingmethodWeight")] + partial class shippingmethodWeight + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserTokens", (string)null); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("City") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CompanyName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Country") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("HouseNumber") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PostalCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("State") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Street") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Categorie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("ImageUrl") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("LastModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("ParentcategorieId") + .HasColumnType("uuid"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.HasIndex("ParentcategorieId"); + + b.HasIndex("Slug") + .IsUnique(); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.CategorieDiscount", b => + { + b.Property("categorieId") + .HasColumnType("uuid"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.HasKey("categorieId", "DiscountId"); + + b.HasIndex("DiscountId"); + + b.ToTable("categorieDiscounts"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AspNetUserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefaultBillingAddressId") + .HasColumnType("uuid"); + + b.Property("DefaultShippingAddressId") + .HasColumnType("uuid"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("AspNetUserId") + .IsUnique(); + + b.ToTable("Customers"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CouponCode") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CurrentUsageCount") + .HasColumnType("integer"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("DiscountType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("DiscountValue") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MaximumUsageCount") + .HasColumnType("integer"); + + b.Property("MinimumOrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("RequiresCouponCode") + .HasColumnType("boolean"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CouponCode") + .IsUnique() + .HasFilter("\"CouponCode\" IS NOT NULL"); + + b.ToTable("Discounts"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AdminNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("BillingAddressId") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("CustomerNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("DeliveredDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DiscountAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("GuestEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("GuestPhoneNumber") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("OrderDate") + .HasColumnType("timestamp with time zone"); + + b.Property("OrderNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrderStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OrderTotal") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PaymentMethod") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PaymentMethodId") + .HasColumnType("uuid"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ShippedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ShippingAddressId") + .HasColumnType("uuid"); + + b.Property("ShippingCost") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ShippingMethodId") + .HasColumnType("uuid"); + + b.Property("ShippingTrackingNumber") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("TaxAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("TransactionId") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.HasIndex("BillingAddressId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("OrderNumber") + .IsUnique(); + + b.HasIndex("PaymentMethodId"); + + b.HasIndex("ShippingAddressId"); + + b.HasIndex("ShippingMethodId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("ProductSKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ProductVariantId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("TotalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductVariantId"); + + b.ToTable("OrderItems"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.PaymentMethod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Configuration") + .HasColumnType("jsonb"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PaymentGatewayType") + .HasColumnType("integer"); + + b.Property("ProcessingFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.HasKey("Id"); + + b.ToTable("PaymentMethods"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("FeaturedDisplayOrder") + .HasColumnType("integer"); + + b.Property("Height") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsFeatured") + .HasColumnType("boolean"); + + b.Property("IsInStock") + .HasColumnType("boolean"); + + b.Property("LastModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Length") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("OldPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PurchasePrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .HasColumnType("bytea"); + + b.Property("SKU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ShortDescription") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("StockQuantity") + .HasColumnType("integer"); + + b.Property("SupplierId") + .HasColumnType("uuid"); + + b.Property("Weight") + .HasPrecision(18, 3) + .HasColumnType("numeric(18,3)"); + + b.Property("Width") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("SKU") + .IsUnique(); + + b.HasIndex("Slug") + .IsUnique(); + + b.HasIndex("SupplierId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b => + { + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.HasKey("ProductId", "DiscountId"); + + b.HasIndex("DiscountId"); + + b.ToTable("ProductDiscounts"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("IsMainImage") + .HasColumnType("boolean"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Url") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductImages", (string)null); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ImageUrl") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PriceAdjustment") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SKU") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("StockQuantity") + .HasColumnType("integer"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductVariants"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b => + { + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("categorieId") + .HasColumnType("uuid"); + + b.HasKey("ProductId", "categorieId"); + + b.HasIndex("categorieId"); + + b.ToTable("Productcategories"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rating") + .HasColumnType("integer"); + + b.Property("ReviewDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ProductId"); + + b.ToTable("Reviews"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Group") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Value") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ShippingMethod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BaseCost") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("EstimatedDeliveryTime") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MaxDeliveryDays") + .HasColumnType("integer"); + + b.Property("MaxWeight") + .HasColumnType("numeric"); + + b.Property("MinDeliveryDays") + .HasColumnType("integer"); + + b.Property("MinWeight") + .HasColumnType("numeric"); + + b.Property("MinimumOrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RequiresTracking") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("ShippingMethods"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ShopInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("City") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CompanyRegistrationNumber") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ContactEmail") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Country") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("PhoneNumber") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PostalCode") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ShopName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Slogan") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Street") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("TwitterUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("VatNumber") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("ShopInfos"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddressId") + .HasColumnType("uuid"); + + b.Property("ContactPerson") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PhoneNumber") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("Webshop.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastActive") + .HasColumnType("timestamp with time zone"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Webshop.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Webshop.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Webshop.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Webshop.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Address", b => + { + b.HasOne("Webshop.Domain.Entities.Customer", "Customer") + .WithMany("Addresses") + .HasForeignKey("CustomerId"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Categorie", b => + { + b.HasOne("Webshop.Domain.Entities.Categorie", "Parentcategorie") + .WithMany("Subcategories") + .HasForeignKey("ParentcategorieId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parentcategorie"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.CategorieDiscount", b => + { + b.HasOne("Webshop.Domain.Entities.Discount", "Discount") + .WithMany("categorieDiscounts") + .HasForeignKey("DiscountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.Categorie", "categorie") + .WithMany("categorieDiscounts") + .HasForeignKey("categorieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discount"); + + b.Navigation("categorie"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Customer", b => + { + b.HasOne("Webshop.Domain.Identity.ApplicationUser", "User") + .WithOne("Customer") + .HasForeignKey("Webshop.Domain.Entities.Customer", "AspNetUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Order", b => + { + b.HasOne("Webshop.Domain.Entities.Address", "BillingAddress") + .WithMany() + .HasForeignKey("BillingAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.Customer", "Customer") + .WithMany("Orders") + .HasForeignKey("CustomerId"); + + b.HasOne("Webshop.Domain.Entities.PaymentMethod", "PaymentMethodInfo") + .WithMany() + .HasForeignKey("PaymentMethodId"); + + b.HasOne("Webshop.Domain.Entities.Address", "ShippingAddress") + .WithMany() + .HasForeignKey("ShippingAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.ShippingMethod", "ShippingMethodInfo") + .WithMany() + .HasForeignKey("ShippingMethodId"); + + b.Navigation("BillingAddress"); + + b.Navigation("Customer"); + + b.Navigation("PaymentMethodInfo"); + + b.Navigation("ShippingAddress"); + + b.Navigation("ShippingMethodInfo"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.OrderItem", b => + { + b.HasOne("Webshop.Domain.Entities.Order", "Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Webshop.Domain.Entities.ProductVariant", "ProductVariant") + .WithMany() + .HasForeignKey("ProductVariantId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Order"); + + b.Navigation("Product"); + + b.Navigation("ProductVariant"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Product", b => + { + b.HasOne("Webshop.Domain.Entities.Supplier", "Supplier") + .WithMany("Products") + .HasForeignKey("SupplierId"); + + b.Navigation("Supplier"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b => + { + b.HasOne("Webshop.Domain.Entities.Discount", "Discount") + .WithMany("ProductDiscounts") + .HasForeignKey("DiscountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany("ProductDiscounts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Discount"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b => + { + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany("Images") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b => + { + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany("Variants") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b => + { + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany("Productcategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Webshop.Domain.Entities.Categorie", "categorie") + .WithMany("Productcategories") + .HasForeignKey("categorieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("categorie"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Review", b => + { + b.HasOne("Webshop.Domain.Entities.Customer", "Customer") + .WithMany("Reviews") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Webshop.Domain.Entities.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Supplier", b => + { + b.HasOne("Webshop.Domain.Entities.Address", "Address") + .WithMany() + .HasForeignKey("AddressId"); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Categorie", b => + { + b.Navigation("Productcategories"); + + b.Navigation("Subcategories"); + + b.Navigation("categorieDiscounts"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Customer", b => + { + b.Navigation("Addresses"); + + b.Navigation("Orders"); + + b.Navigation("Reviews"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Discount", b => + { + b.Navigation("ProductDiscounts"); + + b.Navigation("categorieDiscounts"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Order", b => + { + b.Navigation("OrderItems"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Product", b => + { + b.Navigation("Images"); + + b.Navigation("ProductDiscounts"); + + b.Navigation("Productcategories"); + + b.Navigation("Reviews"); + + b.Navigation("Variants"); + }); + + modelBuilder.Entity("Webshop.Domain.Entities.Supplier", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Webshop.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Customer"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.cs b/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.cs new file mode 100644 index 0000000..d8c3cd4 --- /dev/null +++ b/Webshop.Infrastructure/Migrations/20251126085553_shippingmethodWeight.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Webshop.Infrastructure.Migrations +{ + /// + public partial class shippingmethodWeight : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MaxWeight", + table: "ShippingMethods", + type: "numeric", + nullable: false, + defaultValue: 0m); + + migrationBuilder.AddColumn( + name: "MinWeight", + table: "ShippingMethods", + type: "numeric", + nullable: false, + defaultValue: 0m); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MaxWeight", + table: "ShippingMethods"); + + migrationBuilder.DropColumn( + name: "MinWeight", + table: "ShippingMethods"); + } + } +} diff --git a/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs index f837e11..d14a765 100644 --- a/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Webshop.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -855,9 +855,15 @@ namespace Webshop.Infrastructure.Migrations b.Property("MaxDeliveryDays") .HasColumnType("integer"); + b.Property("MaxWeight") + .HasColumnType("numeric"); + b.Property("MinDeliveryDays") .HasColumnType("integer"); + b.Property("MinWeight") + .HasColumnType("numeric"); + b.Property("MinimumOrderAmount") .HasPrecision(18, 2) .HasColumnType("numeric(18,2)");