diff --git a/Webshop.Api/Controllers/Admin/AdminCategorieController.cs b/Webshop.Api/Controllers/Admin/AdminCategorieController.cs index 4b50ab0..3d627a1 100644 --- a/Webshop.Api/Controllers/Admin/AdminCategorieController.cs +++ b/Webshop.Api/Controllers/Admin/AdminCategorieController.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; using Webshop.Application.Services.Admin; namespace Webshop.Api.Controllers.Admin diff --git a/Webshop.Api/Controllers/Public/CategorieController.cs b/Webshop.Api/Controllers/Public/CategorieController.cs index d7fe773..07fb737 100644 --- a/Webshop.Api/Controllers/Public/CategorieController.cs +++ b/Webshop.Api/Controllers/Public/CategorieController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; using Webshop.Application.Services.Public; namespace Webshop.Api.Controllers.Public diff --git a/Webshop.Api/Program.cs b/Webshop.Api/Program.cs index 7cf37c0..1b33985 100644 --- a/Webshop.Api/Program.cs +++ b/Webshop.Api/Program.cs @@ -79,7 +79,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs b/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs index a64a4c0..8ba86e0 100644 --- a/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs +++ b/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using Webshop.Application.DTOs; using Webshop.Application.DTOs.Auth; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; using Webshop.Application.DTOs.Customers; using Webshop.Application.DTOs.Discounts; using Webshop.Application.DTOs.Email; @@ -29,27 +29,7 @@ namespace Webshop.Api.SwaggerFilters var uniqueId = Guid.NewGuid().ToString().Substring(0, 8); // --- Authentifizierung & Benutzer (Allgemeine Schemas) --- - if (type == typeof(LoginRequestDto)) - { - // Hinweis: Dieses Beispiel wird vom LoginExampleOperationFilter für spezifische Endpunkte überschrieben. - schema.Example = new OpenApiObject - { - ["email"] = new OpenApiString("user@example.com"), - ["password"] = new OpenApiString("Password123!") - }; - } - else if (type == typeof(RegisterRequestDto)) - { - schema.Example = new OpenApiObject - { - ["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"), - ["password"] = new OpenApiString("NeuesPasswort123!"), - ["confirmPassword"] = new OpenApiString("NeuesPasswort123!"), - ["firstName"] = new OpenApiString("Erika"), - ["lastName"] = new OpenApiString("Musterfrau") - }; - } - else if (type == typeof(AuthResponseDto)) + if (type == typeof(AuthResponseDto)) { schema.Example = new OpenApiObject { @@ -79,28 +59,7 @@ namespace Webshop.Api.SwaggerFilters ["defaultBillingAddressId"] = new OpenApiNull() }; } - else if (type == typeof(ResendEmailConfirmationRequestDto)) - { - schema.Example = new OpenApiObject { ["email"] = new OpenApiString("unconfirmed.user@example.com") }; - } - else if (type == typeof(ChangePasswordRequestDto)) - { - schema.Example = new OpenApiObject - { - ["oldPassword"] = new OpenApiString("SecureCustomerPass123!"), - ["newPassword"] = new OpenApiString("NewSecurePass456!"), - ["confirmNewPassword"] = new OpenApiString("NewSecurePass456!") - }; - } - else if (type == typeof(ChangeEmailRequestDto)) - { - schema.Example = new OpenApiObject - { - ["newEmail"] = new OpenApiString($"new.email.{uniqueId}@example.com"), - ["currentPassword"] = new OpenApiString("SecureCustomerPass123!") - }; - } - // --- Produkte & Lieferanten --- + // --- Produkte & Kategorien (Antworten) --- else if (type == typeof(ProductDto)) { schema.Example = new OpenApiObject @@ -126,87 +85,47 @@ namespace Webshop.Api.SwaggerFilters } }; } - else if (type == typeof(AdminProductDto)) - { - schema.Example = new OpenApiObject - { - ["id"] = new OpenApiString(Guid.Empty.ToString()), - ["name"] = new OpenApiString($"Admin Produkt (Beispiel) {uniqueId}"), - ["description"] = new OpenApiString("Detaillierte Beschreibung für das Admin-Produkt."), - ["sku"] = new OpenApiString($"ADM-PROD-{uniqueId}"), - ["price"] = new OpenApiDouble(149.99), - ["oldPrice"] = new OpenApiNull(), - ["isActive"] = new OpenApiBoolean(true), - ["isInStock"] = new OpenApiBoolean(true), - ["stockQuantity"] = new OpenApiInteger(50), - ["weight"] = new OpenApiDouble(1.2), - ["imageUrl"] = new OpenApiString("https://example.com/images/admin_prod.jpg"), - ["slug"] = new OpenApiString($"admin-produkt-beispiel-slug-{uniqueId}"), - ["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")), - ["lastModifiedDate"] = new OpenApiNull(), - ["supplierId"] = new OpenApiNull(), - ["purchasePrice"] = new OpenApiDouble(80.00), - ["categorieIds"] = new OpenApiArray { new OpenApiString("EXISTING_categorie_ID_HERE") } - }; - } - // --- Kategorien --- - else if (type == typeof(CreatecategorieDto)) - { - schema.Example = new OpenApiObject - { - ["name"] = new OpenApiString($"Neue Kategorie {uniqueId}"), - ["slug"] = new OpenApiString($"neue-kategorie-{uniqueId}"), - ["description"] = new OpenApiString("Eine Beschreibung für die neue Kategorie."), - ["parentcategorieId"] = new OpenApiNull(), - ["imageUrl"] = new OpenApiString("https://example.com/images/new_categorie.jpg"), - ["isActive"] = new OpenApiBoolean(true), - ["displayOrder"] = new OpenApiInteger(1) - }; - } - // --- Adressen --- - else if (type == typeof(AddressDto)) + else if (type == typeof(CategorieDto)) { schema.Example = new OpenApiObject { ["id"] = new OpenApiString(Guid.NewGuid().ToString()), - ["street"] = new OpenApiString("Musterstraße"), - ["houseNumber"] = new OpenApiString("123a"), - ["city"] = new OpenApiString("Musterstadt"), - ["postalCode"] = new OpenApiString("12345"), - ["country"] = new OpenApiString("Deutschland"), - ["type"] = new OpenApiString(AddressType.Shipping.ToString()) + ["name"] = new OpenApiString($"Elektronik {uniqueId}"), + ["slug"] = new OpenApiString($"elektronik-{uniqueId}"), + ["description"] = new OpenApiString("Produkte rund um Elektronik."), + ["parentCategorieId"] = new OpenApiNull(), + ["imageUrl"] = new OpenApiString("https://example.com/images/categorie_electronics.jpg"), + ["isActive"] = new OpenApiBoolean(true), + ["displayOrder"] = new OpenApiInteger(1) }; } // --- Kunden --- - else if (type == typeof(UpdateCustomerDto)) + else if (type == typeof(CustomerDto)) { schema.Example = new OpenApiObject { + ["id"] = new OpenApiString(Guid.NewGuid().ToString()), + ["userId"] = new OpenApiString("EIN_IDENTITY_USER_ID_HIER"), ["firstName"] = new OpenApiString("Max"), ["lastName"] = new OpenApiString("Mustermann"), - ["phoneNumber"] = new OpenApiString("+491701234567"), - ["currentPassword"] = new OpenApiString("SecureCustomerPass123!"), + ["email"] = new OpenApiString($"max.mustermann.{uniqueId}@example.com"), + ["phoneNumber"] = new OpenApiString("+491719876543"), ["defaultShippingAddressId"] = new OpenApiNull(), ["defaultBillingAddressId"] = new OpenApiNull() }; } // --- Bestellungen --- - else if (type == typeof(CreateOrderDto)) + else if (type == typeof(OrderSummaryDto)) { schema.Example = new OpenApiObject { - ["shippingAddressId"] = new OpenApiString("VALID_ADDRESS_ID_HERE"), - ["billingAddressId"] = new OpenApiString("VALID_ADDRESS_ID_HERE"), - ["paymentMethodId"] = new OpenApiString("VALID_PAYMENT_METHOD_ID_HERE"), - ["shippingMethodId"] = new OpenApiString("VALID_SHIPPING_METHOD_ID_HERE"), - ["items"] = new OpenApiArray - { - new OpenApiObject - { - ["productId"] = new OpenApiString("VALID_PRODUCT_ID_HERE"), - ["quantity"] = new OpenApiInteger(1) - } - } + ["id"] = new OpenApiString(Guid.NewGuid().ToString()), + ["orderNumber"] = new OpenApiString($"WS-2025-{uniqueId}"), + ["orderDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")), + ["status"] = new OpenApiString(OrderStatus.Processing.ToString()), + ["totalAmount"] = new OpenApiDouble(123.45), + ["paymentStatus"] = new OpenApiString(PaymentStatus.Paid.ToString()), + ["customerName"] = new OpenApiString("Max Mustermann") }; } } diff --git a/Webshop.Application/DTOs/Categories/CategorieDto.cs b/Webshop.Application/DTOs/Categories/CategorieDto.cs index 29a682f..4b6704d 100644 --- a/Webshop.Application/DTOs/Categories/CategorieDto.cs +++ b/Webshop.Application/DTOs/Categories/CategorieDto.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Webshop.Application.DTOs.categories +namespace Webshop.Application.DTOs.Categorie { public class CategorieDto { diff --git a/Webshop.Application/DTOs/Categories/CreateCategorieDto.cs b/Webshop.Application/DTOs/Categories/CreateCategorieDto.cs index f5d0dc6..5df5220 100644 --- a/Webshop.Application/DTOs/Categories/CreateCategorieDto.cs +++ b/Webshop.Application/DTOs/Categories/CreateCategorieDto.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Webshop.Application.DTOs.categories +namespace Webshop.Application.DTOs.Categorie { public class CreatecategorieDto { diff --git a/Webshop.Application/DTOs/Products/ProductDto.cs b/Webshop.Application/DTOs/Products/ProductDto.cs index a2a7f20..cdaeed2 100644 --- a/Webshop.Application/DTOs/Products/ProductDto.cs +++ b/Webshop.Application/DTOs/Products/ProductDto.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; namespace Webshop.Application.DTOs.Products diff --git a/Webshop.Application/Services/Admin/AdminCategorieService.cs b/Webshop.Application/Services/Admin/AdminCategorieService.cs index 2cb78be..40e45bd 100644 --- a/Webshop.Application/Services/Admin/AdminCategorieService.cs +++ b/Webshop.Application/Services/Admin/AdminCategorieService.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; @@ -11,9 +11,9 @@ namespace Webshop.Application.Services.Admin { public class AdminCategorieService : IAdminCategorieService { - private readonly IcategorieRepository _categorieRepository; + private readonly ICategorieRepository _categorieRepository; - public AdminCategorieService(IcategorieRepository categorieRepository) + public AdminCategorieService(ICategorieRepository categorieRepository) { _categorieRepository = categorieRepository; } @@ -60,7 +60,7 @@ namespace Webshop.Application.Services.Admin return (null, "Eine Kategorie mit diesem Slug existiert bereits."); } - var categorie = new categorie + var categorie = new Categorie { Id = Guid.NewGuid(), Name = categorieDto.Name, diff --git a/Webshop.Application/Services/Admin/Interfaces/IAdminCategorieService.cs b/Webshop.Application/Services/Admin/Interfaces/IAdminCategorieService.cs index 039476a..ac4632e 100644 --- a/Webshop.Application/Services/Admin/Interfaces/IAdminCategorieService.cs +++ b/Webshop.Application/Services/Admin/Interfaces/IAdminCategorieService.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; namespace Webshop.Application.Services.Admin { diff --git a/Webshop.Application/Services/Public/CategorieService.cs b/Webshop.Application/Services/Public/CategorieService.cs index 48a8bc2..fc35959 100644 --- a/Webshop.Application/Services/Public/CategorieService.cs +++ b/Webshop.Application/Services/Public/CategorieService.cs @@ -2,16 +2,16 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; using Webshop.Domain.Interfaces; namespace Webshop.Application.Services.Public { public class CategorieService : ICategorieService { - private readonly IcategorieRepository _categorieRepository; + private readonly ICategorieRepository _categorieRepository; - public CategorieService(IcategorieRepository categorieRepository) + public CategorieService(ICategorieRepository categorieRepository) { _categorieRepository = categorieRepository; } diff --git a/Webshop.Application/Services/Public/Interfaces/ICategorieService.cs b/Webshop.Application/Services/Public/Interfaces/ICategorieService.cs index 56830f7..b554fe4 100644 --- a/Webshop.Application/Services/Public/Interfaces/ICategorieService.cs +++ b/Webshop.Application/Services/Public/Interfaces/ICategorieService.cs @@ -1,7 +1,7 @@ // src/Webshop.Application/Services/Public/Icategorieservice.cs using System.Collections.Generic; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; +using Webshop.Application.DTOs.Categorie; namespace Webshop.Application.Services.Public { diff --git a/Webshop.Application/Services/Public/ProductService.cs b/Webshop.Application/Services/Public/ProductService.cs index 79f3945..9c2843c 100644 --- a/Webshop.Application/Services/Public/ProductService.cs +++ b/Webshop.Application/Services/Public/ProductService.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore; // << NEU: Für Include() und ThenInclude() using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Webshop.Application.DTOs.categories; // Für categorieDto +using Webshop.Application.DTOs.Categorie; // Für categorieDto using Webshop.Application.DTOs.Products; // Für ProductDto using Webshop.Application.Services.Public.Interfaces; // Für IProductService using Webshop.Domain.Interfaces; // Für IProductRepository diff --git a/Webshop.Domain/Entities/Categorie.cs b/Webshop.Domain/Entities/Categorie.cs index 2a7196f..3d4e017 100644 --- a/Webshop.Domain/Entities/Categorie.cs +++ b/Webshop.Domain/Entities/Categorie.cs @@ -9,7 +9,7 @@ namespace Webshop.Domain.Entities /// /// Zum Gruppieren und Organisieren von Produkten. /// - public class categorie + public class Categorie { [Key] public Guid Id { get; set; } = Guid.NewGuid(); // Hinzufügen von Default-Wert @@ -43,9 +43,9 @@ namespace Webshop.Domain.Entities // << ENDE NEUE EIGENSCHAFTEN >> // Navigation Properties - public virtual categorie? Parentcategorie { get; set; } - public virtual ICollection Subcategories { get; set; } = new List(); + public virtual Categorie? Parentcategorie { get; set; } + public virtual ICollection Subcategories { get; set; } = new List(); public virtual ICollection Productcategories { get; set; } = new List(); - public virtual ICollection categorieDiscounts { get; set; } = new List(); + public virtual ICollection categorieDiscounts { get; set; } = new List(); } } \ No newline at end of file diff --git a/Webshop.Domain/Entities/CategorieDiscount.cs b/Webshop.Domain/Entities/CategorieDiscount.cs index b51f346..d1535d3 100644 --- a/Webshop.Domain/Entities/CategorieDiscount.cs +++ b/Webshop.Domain/Entities/CategorieDiscount.cs @@ -7,7 +7,7 @@ namespace Webshop.Domain.Entities; /// /// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen categorie und Discount. /// -public class categorieDiscount +public class CategorieDiscount { [Required] [ForeignKey(nameof(categorie))] @@ -18,6 +18,6 @@ public class categorieDiscount public Guid DiscountId { get; set; } // Navigation Properties - public virtual categorie categorie { get; set; } + public virtual Categorie categorie { get; set; } public virtual Discount Discount { get; set; } } \ No newline at end of file diff --git a/Webshop.Domain/Entities/Discount.cs b/Webshop.Domain/Entities/Discount.cs index 0d9da8d..7ee30a1 100644 --- a/Webshop.Domain/Entities/Discount.cs +++ b/Webshop.Domain/Entities/Discount.cs @@ -51,5 +51,5 @@ public class Discount // Navigation Properties public virtual ICollection ProductDiscounts { get; set; } = new List(); - public virtual ICollection categorieDiscounts { get; set; } = new List(); + public virtual ICollection categorieDiscounts { get; set; } = new List(); } \ No newline at end of file diff --git a/Webshop.Domain/Entities/ProductCategorie.cs b/Webshop.Domain/Entities/ProductCategorie.cs index b140e42..25d3724 100644 --- a/Webshop.Domain/Entities/ProductCategorie.cs +++ b/Webshop.Domain/Entities/ProductCategorie.cs @@ -20,5 +20,5 @@ public class Productcategorie // Navigation Properties public virtual Product Product { get; set; } - public virtual categorie categorie { get; set; } + public virtual Categorie categorie { get; set; } } \ No newline at end of file diff --git a/Webshop.Domain/Interfaces/ICategorieRepository.cs b/Webshop.Domain/Interfaces/ICategorieRepository.cs index 3429cc5..11bcfc3 100644 --- a/Webshop.Domain/Interfaces/ICategorieRepository.cs +++ b/Webshop.Domain/Interfaces/ICategorieRepository.cs @@ -6,13 +6,13 @@ using Webshop.Domain.Entities; namespace Webshop.Domain.Interfaces { - public interface IcategorieRepository + public interface ICategorieRepository { - Task> GetAllAsync(); - Task GetByIdAsync(Guid id); - Task GetBySlugAsync(string slug); - Task AddAsync(categorie categorie); - Task UpdateAsync(categorie categorie); + Task> GetAllAsync(); + Task GetByIdAsync(Guid id); + Task GetBySlugAsync(string slug); + Task AddAsync(Categorie categorie); + Task UpdateAsync(Categorie categorie); Task DeleteAsync(Guid id); } } \ No newline at end of file diff --git a/Webshop.Infrastructure/Data/ApplicationDbContext.cs b/Webshop.Infrastructure/Data/ApplicationDbContext.cs index a97c6a0..925b5d4 100644 --- a/Webshop.Infrastructure/Data/ApplicationDbContext.cs +++ b/Webshop.Infrastructure/Data/ApplicationDbContext.cs @@ -14,7 +14,7 @@ namespace Webshop.Infrastructure.Data public DbSet Products { get; set; } = default!; public DbSet ProductVariants { get; set; } = default!; - public DbSet categories { get; set; } = default!; + public DbSet categories { get; set; } = default!; public DbSet Customers { get; set; } = default!; public DbSet
Addresses { get; set; } = default!; public DbSet Orders { get; set; } = default!; @@ -28,7 +28,7 @@ namespace Webshop.Infrastructure.Data public DbSet Productcategories { get; set; } = default!; public DbSet ProductDiscounts { get; set; } = default!; - public DbSet categorieDiscounts { get; set; } = default!; + public DbSet categorieDiscounts { get; set; } = default!; protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -47,11 +47,11 @@ namespace Webshop.Infrastructure.Data modelBuilder.Entity().HasKey(pc => new { pc.ProductId, pc.categorieId }); modelBuilder.Entity().HasKey(pd => new { pd.ProductId, pd.DiscountId }); - modelBuilder.Entity().HasKey(cd => new { cd.categorieId, cd.DiscountId }); + modelBuilder.Entity().HasKey(cd => new { cd.categorieId, cd.DiscountId }); modelBuilder.Entity().HasIndex(p => p.SKU).IsUnique(); modelBuilder.Entity().HasIndex(p => p.Slug).IsUnique(); - modelBuilder.Entity().HasIndex(c => c.Slug).IsUnique(); + modelBuilder.Entity().HasIndex(c => c.Slug).IsUnique(); modelBuilder.Entity().HasIndex(d => d.CouponCode).IsUnique().HasFilter("\"CouponCode\" IS NOT NULL"); modelBuilder.Entity().HasIndex(s => s.Key).IsUnique(); modelBuilder.Entity().HasIndex(o => o.OrderNumber).IsUnique(); @@ -99,7 +99,7 @@ namespace Webshop.Infrastructure.Data modelBuilder.Entity() .Property(pm => pm.ProcessingFee).HasPrecision(18, 2); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(c => c.Parentcategorie) .WithMany(c => c.Subcategories) .HasForeignKey(c => c.ParentcategorieId) diff --git a/Webshop.Infrastructure/Repositories/CategorieRepository.cs b/Webshop.Infrastructure/Repositories/CategorieRepository.cs index 9191aa7..b01a547 100644 --- a/Webshop.Infrastructure/Repositories/CategorieRepository.cs +++ b/Webshop.Infrastructure/Repositories/CategorieRepository.cs @@ -9,37 +9,37 @@ using Webshop.Infrastructure.Data; namespace Webshop.Infrastructure.Repositories { - public class categorieRepository : IcategorieRepository + public class CategorieRepository : ICategorieRepository { private readonly ApplicationDbContext _context; - public categorieRepository(ApplicationDbContext context) + public CategorieRepository(ApplicationDbContext context) { _context = context; } - public async Task> GetAllAsync() + public async Task> GetAllAsync() { return await _context.categories.ToListAsync(); } - public async Task GetByIdAsync(Guid id) + public async Task GetByIdAsync(Guid id) { return await _context.categories.FindAsync(id); } - public async Task GetBySlugAsync(string slug) + public async Task GetBySlugAsync(string slug) { return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug); } - public async Task AddAsync(categorie categorie) + public async Task AddAsync(Categorie categorie) { _context.categories.Add(categorie); await _context.SaveChangesAsync(); } - public async Task UpdateAsync(categorie categorie) + public async Task UpdateAsync(Categorie categorie) { _context.categories.Update(categorie); await _context.SaveChangesAsync();