dtos neu und aufräumen
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
|
using Webshop.Application.DTOs.Email;
|
||||||
using Webshop.Application.Services.Auth;
|
using Webshop.Application.Services.Auth;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -14,12 +15,6 @@ namespace Webshop.Api.Controllers.Auth // Beachten Sie den Namespace
|
|||||||
private readonly IAuthService _authService;
|
private readonly IAuthService _authService;
|
||||||
private readonly ICustomerService _customerService;
|
private readonly ICustomerService _customerService;
|
||||||
|
|
||||||
public class ResendEmailConfirmationRequestDto
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
[EmailAddress]
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthController(IAuthService authService, ICustomerService customerService)
|
public AuthController(IAuthService authService, ICustomerService customerService)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Security.Claims;
|
|||||||
using Webshop.Application.DTOs; // CustomerDto
|
using Webshop.Application.DTOs; // CustomerDto
|
||||||
using Webshop.Application.DTOs.Auth; // ChangePasswordRequestDto
|
using Webshop.Application.DTOs.Auth; // ChangePasswordRequestDto
|
||||||
using Webshop.Application.DTOs.Customers; // UpdateCustomerProfileDto
|
using Webshop.Application.DTOs.Customers; // UpdateCustomerProfileDto
|
||||||
|
using Webshop.Application.DTOs.Email;
|
||||||
using Webshop.Application.Services;
|
using Webshop.Application.Services;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.Services.Customers;
|
using Webshop.Application.Services.Customers;
|
||||||
@@ -12,15 +13,6 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace Webshop.Api.Controllers.Customer
|
namespace Webshop.Api.Controllers.Customer
|
||||||
{
|
{
|
||||||
public class ChangeEmailRequestDto
|
|
||||||
{
|
|
||||||
[Required(ErrorMessage = "Neue E-Mail ist erforderlich.")]
|
|
||||||
[EmailAddress(ErrorMessage = "Ung<6E>ltiges E-Mail-Format.")]
|
|
||||||
public string NewEmail { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Aktuelles Passwort ist erforderlich.")]
|
|
||||||
public string CurrentPassword { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/[controller]")] // z.B. /api/v1/customer/profile
|
[Route("api/v1/[controller]")] // z.B. /api/v1/customer/profile
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
// src/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs
|
// src/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs
|
||||||
|
using Microsoft.OpenApi.Any;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using Microsoft.OpenApi.Any;
|
using System; // Für Guid.NewGuid()
|
||||||
using Webshop.Application.DTOs;
|
using Webshop.Application.DTOs; // Allgemeine DTOs wie AdminProductDto, ProductDto, SupplierDto
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Categorys; // Korrekter Namespace
|
||||||
using System;
|
|
||||||
using Webshop.Application.DTOs.Customers;
|
using Webshop.Application.DTOs.Customers;
|
||||||
|
using Webshop.Application.DTOs.Discounts;
|
||||||
|
using Webshop.Application.DTOs.Email; // Für ResendEmailConfirmationRequestDto
|
||||||
|
using Webshop.Application.DTOs.Orders;
|
||||||
|
using Webshop.Application.DTOs.Payments;
|
||||||
|
using Webshop.Application.DTOs.Products;
|
||||||
|
using Webshop.Application.DTOs.Reviews;
|
||||||
using Webshop.Application.DTOs.Shipping;
|
using Webshop.Application.DTOs.Shipping;
|
||||||
using Webshop.Application.DTOs.Suppliers;
|
using Webshop.Application.DTOs.Suppliers;
|
||||||
using Webshop.Application.DTOs.Reviews;
|
using Webshop.Application.DTOs.Users;
|
||||||
using Webshop.Application.DTOs.Products;
|
|
||||||
using Webshop.Application.DTOs.Payments;
|
|
||||||
using Webshop.Application.DTOs.Orders;
|
|
||||||
using Webshop.Application.DTOs.Discounts;
|
|
||||||
using Webshop.Application.DTOs.Categorys;
|
|
||||||
using Webshop.Api.Controllers.Auth;
|
|
||||||
using Webshop.Domain.Enums;
|
using Webshop.Domain.Enums;
|
||||||
|
|
||||||
namespace Webshop.Api.SwaggerFilters
|
namespace Webshop.Api.SwaggerFilters
|
||||||
@@ -25,12 +25,12 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
||||||
{
|
{
|
||||||
var type = context.Type;
|
var type = context.Type;
|
||||||
// Eine eindeutige Kennung, die wir an SKU/Slug anhängen können
|
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8);
|
||||||
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8); // Z.B. 8 Zeichen der GUID
|
|
||||||
|
|
||||||
// --- Authentifizierung & Benutzer (Allgemeine Schemas) ---
|
// --- Authentifizierung & Benutzer (Allgemeine Schemas) ---
|
||||||
if (type == typeof(LoginRequestDto))
|
if (type == typeof(LoginRequestDto))
|
||||||
{
|
{
|
||||||
|
// Hinweis: Dieses Beispiel wird vom LoginExampleOperationFilter für spezifische Endpunkte überschrieben.
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["email"] = new OpenApiString("user@example.com"),
|
["email"] = new OpenApiString("user@example.com"),
|
||||||
@@ -41,7 +41,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"), // Eindeutige E-Mail
|
["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"),
|
||||||
["password"] = new OpenApiString("NeuesPasswort123!"),
|
["password"] = new OpenApiString("NeuesPasswort123!"),
|
||||||
["confirmPassword"] = new OpenApiString("NeuesPasswort123!"),
|
["confirmPassword"] = new OpenApiString("NeuesPasswort123!"),
|
||||||
["firstName"] = new OpenApiString("Erika"),
|
["firstName"] = new OpenApiString("Erika"),
|
||||||
@@ -72,11 +72,11 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["emailConfirmed"] = new OpenApiBoolean(true)
|
["emailConfirmed"] = new OpenApiBoolean(true)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (type == typeof(AuthController.ResendEmailConfirmationRequestDto))
|
else if (type == typeof(ResendEmailConfirmationRequestDto)) // DTO verschoben nach Application/DTOs/Email
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["email"] = new OpenApiString("me@tzbre.dev")
|
["email"] = new OpenApiString("unconfirmed.user@example.com")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// --- Produkte & Lieferanten ---
|
// --- Produkte & Lieferanten ---
|
||||||
@@ -113,7 +113,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["slug"] = new OpenApiString($"admin-produkt-beispiel-slug-{uniqueId}"),
|
["slug"] = new OpenApiString($"admin-produkt-beispiel-slug-{uniqueId}"),
|
||||||
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
|
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
|
||||||
["lastModifiedDate"] = new OpenApiNull(),
|
["lastModifiedDate"] = new OpenApiNull(),
|
||||||
["supplierId"] = new OpenApiNull(), // ODER new OpenApiString("IHR-ECHTER-LIEFERANTEN-GUID-HIER")
|
["supplierId"] = new OpenApiNull(),
|
||||||
["purchasePrice"] = new OpenApiDouble(80.00)
|
["purchasePrice"] = new OpenApiDouble(80.00)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -209,13 +209,11 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["firstName"] = new OpenApiString("Max"),
|
["firstName"] = new OpenApiString("Max"),
|
||||||
["lastName"] = new OpenApiString("Mustermann"),
|
["lastName"] = new OpenApiString("Mustermann"),
|
||||||
["phoneNumber"] = new OpenApiString("+491701234567"),
|
["phoneNumber"] = new OpenApiString("+491701234567"),
|
||||||
// ["email"] = new OpenApiString($"max.mustermann.neu.{uniqueId}@example.com"), // << ENTFERNT >>
|
|
||||||
["currentPassword"] = new OpenApiString("SecureCustomerPass123!"),
|
["currentPassword"] = new OpenApiString("SecureCustomerPass123!"),
|
||||||
["defaultShippingAddressId"] = new OpenApiNull(),
|
["defaultShippingAddressId"] = new OpenApiNull(),
|
||||||
["defaultBillingAddressId"] = new OpenApiNull()
|
["defaultBillingAddressId"] = new OpenApiNull()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Rabatte ---
|
// --- Rabatte ---
|
||||||
else if (type == typeof(DiscountDto))
|
else if (type == typeof(DiscountDto))
|
||||||
{
|
{
|
||||||
@@ -226,13 +224,12 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["description"] = new OpenApiString("10% Rabatt auf alles"),
|
["description"] = new OpenApiString("10% Rabatt auf alles"),
|
||||||
["type"] = new OpenApiString(DiscountType.Percentage.ToString()),
|
["type"] = new OpenApiString(DiscountType.Percentage.ToString()),
|
||||||
["value"] = new OpenApiDouble(10.00),
|
["value"] = new OpenApiDouble(10.00),
|
||||||
["couponCode"] = new OpenApiString($"SOMMER-{uniqueId}"), // Optional, muss eindeutig sein
|
["couponCode"] = new OpenApiString($"SOMMER-{uniqueId}"),
|
||||||
["startDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(1).ToString("o")),
|
["startDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(1).ToString("o")),
|
||||||
["endDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(30).ToString("o")),
|
["endDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(30).ToString("o")),
|
||||||
["isActive"] = new OpenApiBoolean(true),
|
["isActive"] = new OpenApiBoolean(true),
|
||||||
["maxUses"] = new OpenApiInteger(100),
|
["maxUses"] = new OpenApiInteger(100),
|
||||||
["currentUses"] = new OpenApiInteger(0),
|
["currentUses"] = new OpenApiInteger(0)
|
||||||
["description"] = new OpenApiString("Gültig vom 1. September bis 30. September.")
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// --- Bestellungen ---
|
// --- Bestellungen ---
|
||||||
@@ -334,7 +331,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["key"] = new OpenApiString($"GlobalTaxRate-{uniqueId}"), // Für POST: Muss eindeutig sein
|
["key"] = new OpenApiString($"GlobalTaxRate-{uniqueId}"),
|
||||||
["value"] = new OpenApiString("0.19"),
|
["value"] = new OpenApiString("0.19"),
|
||||||
["description"] = new OpenApiString("Allgemeiner Mehrwertsteuersatz"),
|
["description"] = new OpenApiString("Allgemeiner Mehrwertsteuersatz"),
|
||||||
["lastModifiedDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o"))
|
["lastModifiedDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o"))
|
||||||
|
|||||||
19
Webshop.Application/DTOs/Email/ChangeEmailRequestDto.cs
Normal file
19
Webshop.Application/DTOs/Email/ChangeEmailRequestDto.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Webshop.Application.DTOs.Email
|
||||||
|
{
|
||||||
|
public class ChangeEmailRequestDto
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Neue E-Mail ist erforderlich.")]
|
||||||
|
[EmailAddress(ErrorMessage = "Ungültiges E-Mail-Format.")]
|
||||||
|
public string NewEmail { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Aktuelles Passwort ist erforderlich.")]
|
||||||
|
public string CurrentPassword { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Webshop.Application.DTOs.Email
|
||||||
|
{
|
||||||
|
public class ResendEmailConfirmationRequestDto
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
[EmailAddress]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user