aufrüumen
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Application.Services.Admin;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Products;
|
||||
using Webshop.Application.Services.Admin.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Admin
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Application.Services.Admin; // Wichtig f<>r IAdminSupplierService
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Suppliers;
|
||||
using Webshop.Application.Services.Admin.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Admin
|
||||
{
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Webshop.Application.DTOs.Users;
|
||||
using Webshop.Application.Services.Admin;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.Services.Admin.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Admin
|
||||
{
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
[Authorize(Roles = "Customer")]
|
||||
public class ProfileController : ControllerBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
namespace Webshop.Api.Controllers.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
namespace Webshop.Api.Controllers.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
51
Webshop.Api/Controllers/Customers/ProfileController.cs
Normal file
51
Webshop.Api/Controllers/Customers/ProfileController.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.Services.Customers.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/profile")] // Eindeutige Route f<>r das Profil
|
||||
[Authorize(Roles = "Customer")] // Nur f<>r eingeloggte Kunden!
|
||||
public class ProfileController : ControllerBase
|
||||
{
|
||||
private readonly ICustomerService _customerService;
|
||||
|
||||
public ProfileController(ICustomerService customerService)
|
||||
{
|
||||
_customerService = customerService;
|
||||
}
|
||||
|
||||
// Hilfsmethode, um die ID des eingeloggten Benutzers aus dem Token zu holen
|
||||
private string GetUserId() => User.FindFirstValue(ClaimTypes.NameIdentifier)!;
|
||||
|
||||
[HttpGet("me")] // GET /api/v1/customer/profile/me
|
||||
public async Task<ActionResult<CustomerDto>> GetMyProfile()
|
||||
{
|
||||
var userId = GetUserId();
|
||||
var profile = await _customerService.GetMyProfileAsync(userId);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
return NotFound("Kundenprofil nicht gefunden.");
|
||||
}
|
||||
return Ok(profile);
|
||||
}
|
||||
|
||||
[HttpPut("me")] // PUT /api/v1/customer/profile/me
|
||||
public async Task<IActionResult> UpdateMyProfile([FromBody] UpdateCustomerProfileDto profileDto)
|
||||
{
|
||||
var userId = GetUserId();
|
||||
var success = await _customerService.UpdateMyProfileAsync(userId, profileDto);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
return NotFound("Kundenprofil nicht gefunden.");
|
||||
}
|
||||
return NoContent(); // Standardantwort f<>r ein erfolgreiches Update
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
namespace Webshop.Api.Controllers.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
@@ -1,12 +1,12 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Application.Services.Public;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Products;
|
||||
|
||||
namespace Webshop.Api.Controllers.Public
|
||||
{
|
||||
|
||||
@@ -14,6 +14,10 @@ using Microsoft.Extensions.Logging; // For ILogger
|
||||
using Microsoft.OpenApi.Models; // For Swagger OpenAPI models
|
||||
using Webshop.Api.SwaggerFilters; // For AuthorizeOperationFilter
|
||||
using Webshop.Domain.Entities;
|
||||
using Webshop.Application.Services.Admin.Interfaces;
|
||||
using Webshop.Application.Services.Public.Interfaces;
|
||||
using Webshop.Application.Services.Customers.Interfaces;
|
||||
using Webshop.Application.Services.Customers;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -85,7 +89,7 @@ builder.Services.AddScoped<IAdminProductService, AdminProductService>();
|
||||
builder.Services.AddScoped<IAdminSupplierService, AdminSupplierService>();
|
||||
|
||||
// CUSTOMER Services (sp<73>ter Implementierungen hinzuf<75>gen)
|
||||
// builder.Services.AddScoped<CustomerOrderService>();
|
||||
builder.Services.AddScoped<ICustomerService, CustomerService>();
|
||||
|
||||
|
||||
// 5. Controller und Swagger/OpenAPI hinzuf<75>gen
|
||||
|
||||
@@ -5,7 +5,16 @@ using Microsoft.OpenApi.Any;
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Application.DTOs.Auth;
|
||||
using Webshop.Application.DTOs.Users;
|
||||
using System; // Für Guid.NewGuid()
|
||||
using System;
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.DTOs.Shipping;
|
||||
using Webshop.Application.DTOs.Suppliers;
|
||||
using Webshop.Application.DTOs.Reviews;
|
||||
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; // Für Guid.NewGuid()
|
||||
|
||||
namespace Webshop.Api.SwaggerFilters
|
||||
{
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>461c56b2-b056-42a9-8ce5-ccc441ef8a37</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>461c56b2-b056-42a9-8ce5-ccc441ef8a37</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.18">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Webshop.Application\Webshop.Application.csproj" />
|
||||
<ProjectReference Include="..\Webshop.Infrastructure\Webshop.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
||||
|
||||
</Project>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.18">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Webshop.Application\Webshop.Application.csproj" />
|
||||
<ProjectReference Include="..\Webshop.Infrastructure\Webshop.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user