This commit is contained in:
Tizian.Breuch
2025-08-01 15:21:40 +02:00
parent 4dfc50d572
commit 1317844ce5
19 changed files with 66 additions and 147 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -79,7 +79,7 @@ builder.Services.AddScoped<IProductRepository, ProductRepository>();
builder.Services.AddScoped<ISupplierRepository, SupplierRepository>();
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
builder.Services.AddScoped<IPaymentMethodRepository, PaymentMethodRepository>();
builder.Services.AddScoped<IcategorieRepository, categorieRepository>();
builder.Services.AddScoped<ICategorieRepository, CategorieRepository>();
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
builder.Services.AddScoped<IShippingMethodRepository, ShippingMethodRepository>();
builder.Services.AddScoped<IAddressRepository, AddressRepository>();

View File

@@ -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")
};
}
}