aufrüumen
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
// Auto-generiert von CreateWebshopFiles.ps1
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Application.Services.Admin;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Products;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Admin
|
namespace Webshop.Api.Controllers.Admin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs
|
// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Application.Services.Admin; // Wichtig f<>r IAdminSupplierService
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Suppliers;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Admin
|
namespace Webshop.Api.Controllers.Admin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
using Webshop.Application.Services.Admin;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Admin
|
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.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Customer
|
namespace Webshop.Api.Controllers.Customers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/customer/[controller]")]
|
[Route("api/v1/customer/[controller]")]
|
||||||
@@ -6,7 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Customer
|
namespace Webshop.Api.Controllers.Customers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/customer/[controller]")]
|
[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.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Customer
|
namespace Webshop.Api.Controllers.Customers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/customer/[controller]")]
|
[Route("api/v1/customer/[controller]")]
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
// Auto-generiert von CreateWebshopFiles.ps1
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Application.Services.Public;
|
using Webshop.Application.Services.Public;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Products;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Public
|
namespace Webshop.Api.Controllers.Public
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ using Microsoft.Extensions.Logging; // For ILogger
|
|||||||
using Microsoft.OpenApi.Models; // For Swagger OpenAPI models
|
using Microsoft.OpenApi.Models; // For Swagger OpenAPI models
|
||||||
using Webshop.Api.SwaggerFilters; // For AuthorizeOperationFilter
|
using Webshop.Api.SwaggerFilters; // For AuthorizeOperationFilter
|
||||||
using Webshop.Domain.Entities;
|
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);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ builder.Services.AddScoped<IAdminProductService, AdminProductService>();
|
|||||||
builder.Services.AddScoped<IAdminSupplierService, AdminSupplierService>();
|
builder.Services.AddScoped<IAdminSupplierService, AdminSupplierService>();
|
||||||
|
|
||||||
// CUSTOMER Services (sp<73>ter Implementierungen hinzuf<75>gen)
|
// 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. Controller und Swagger/OpenAPI hinzuf<75>gen
|
||||||
|
|||||||
@@ -5,7 +5,16 @@ using Microsoft.OpenApi.Any;
|
|||||||
using Webshop.Application.DTOs;
|
using Webshop.Application.DTOs;
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
using Webshop.Application.DTOs.Users;
|
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
|
namespace Webshop.Api.SwaggerFilters
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,11 +9,14 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.18">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.18">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -9,19 +9,10 @@ namespace Webshop.Application.DTOs.Auth
|
|||||||
{
|
{
|
||||||
public class RegisterRequestDto
|
public class RegisterRequestDto
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "E-Mail ist erforderlich.")]
|
[Required][EmailAddress] public string Email { get; set; } = string.Empty;
|
||||||
[EmailAddress(ErrorMessage = "Ungültiges E-Mail-Format.")]
|
[Required][MinLength(6)] public string Password { get; set; } = string.Empty;
|
||||||
public string Email { get; set; } = string.Empty;
|
[Required][Compare("Password")] public string ConfirmPassword { get; set; } = string.Empty;
|
||||||
|
[Required] public string FirstName { get; set; } = string.Empty;
|
||||||
[Required(ErrorMessage = "Passwort ist erforderlich.")]
|
[Required] public string LastName { get; set; } = string.Empty;
|
||||||
[MinLength(6, ErrorMessage = "Passwort muss mindestens 6 Zeichen lang sein.")]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Passwortbestätigung ist erforderlich.")]
|
|
||||||
[Compare("Password", ErrorMessage = "Passwörter stimmen nicht überein.")]
|
|
||||||
public string ConfirmPassword { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string? FirstName { get; set; }
|
|
||||||
public string? LastName { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Categorys
|
||||||
{
|
{
|
||||||
public class CategoryDto
|
public class CategoryDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Categorys
|
||||||
{
|
{
|
||||||
public class CreateCategoryDto
|
public class CreateCategoryDto
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Customers
|
||||||
{
|
{
|
||||||
public class AddressDto
|
public class AddressDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Customers
|
||||||
{
|
{
|
||||||
public class CustomerDto
|
public class CustomerDto
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Webshop.Application.DTOs.Customers
|
||||||
|
{
|
||||||
|
public class UpdateCustomerProfileDto
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string FirstName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string LastName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
// PhoneNumber könnte auch hier sein, falls der User das ändern darf
|
||||||
|
// public string? PhoneNumber { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Discounts
|
||||||
{
|
{
|
||||||
public class DiscountDto
|
public class DiscountDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Orders
|
||||||
{
|
{
|
||||||
public class CreateOrderDto
|
public class CreateOrderDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Orders
|
||||||
{
|
{
|
||||||
public class CreateOrderItemDto
|
public class CreateOrderItemDto
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Orders
|
||||||
{
|
{
|
||||||
public class OrderDetailDto
|
public class OrderDetailDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Orders
|
||||||
{
|
{
|
||||||
public class OrderItemDto
|
public class OrderItemDto
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Orders
|
||||||
{
|
{
|
||||||
public class OrderSummaryDto
|
public class OrderSummaryDto
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Payments
|
||||||
{
|
{
|
||||||
public class PaymentMethodDto
|
public class PaymentMethodDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Products
|
||||||
{
|
{
|
||||||
public class AdminProductDto
|
public class AdminProductDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Products
|
||||||
{
|
{
|
||||||
public class ProductDto
|
public class ProductDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Products
|
||||||
{
|
{
|
||||||
public class ProductVariantDto
|
public class ProductVariantDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Reviews
|
||||||
{
|
{
|
||||||
public class CreateReviewDto
|
public class CreateReviewDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Reviews
|
||||||
{
|
{
|
||||||
public class ReviewDto
|
public class ReviewDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Shipping
|
||||||
{
|
{
|
||||||
public class ShippingMethodDto
|
public class ShippingMethodDto
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs
|
namespace Webshop.Application.DTOs.Suppliers
|
||||||
{
|
{
|
||||||
public class SupplierDto
|
public class SupplierDto
|
||||||
{
|
{
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
// src/Webshop.Application/DTOs/Users/UserDto.cs
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.Users
|
namespace Webshop.Application.DTOs.Users
|
||||||
{
|
{
|
||||||
public class UserDto
|
public class UserDto
|
||||||
@@ -14,5 +9,10 @@ namespace Webshop.Application.DTOs.Users
|
|||||||
public List<string> Roles { get; set; } = new List<string>();
|
public List<string> Roles { get; set; } = new List<string>();
|
||||||
public DateTimeOffset CreatedDate { get; set; }
|
public DateTimeOffset CreatedDate { get; set; }
|
||||||
public bool EmailConfirmed { get; set; }
|
public bool EmailConfirmed { get; set; }
|
||||||
|
|
||||||
|
// Hinzugef<65>gte Felder
|
||||||
|
public DateTimeOffset? LastActive { get; set; }
|
||||||
|
public string FirstName { get; set; } = string.Empty;
|
||||||
|
public string LastName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// src/Webshop.Application/Services/Admin/AdminProductService.cs
|
// src/Webshop.Application/Services/Admin/AdminProductService.cs
|
||||||
using Webshop.Application.DTOs; // AdminProductDto
|
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
using Webshop.Domain.Interfaces;
|
using Webshop.Domain.Interfaces;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System; // F<>r Guid
|
using System; // F<>r Guid
|
||||||
using System.Linq; // F<>r Select
|
using System.Linq;
|
||||||
|
using Webshop.Application.DTOs.Products;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces; // F<>r Select
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// src/Webshop.Application/Services/Admin/AdminSupplierService.cs
|
// src/Webshop.Application/Services/Admin/AdminSupplierService.cs
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
using Webshop.Domain.Interfaces; // Wichtig für ISupplierRepository
|
using Webshop.Domain.Interfaces; // Wichtig für ISupplierRepository
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Suppliers;
|
||||||
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,27 +5,34 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
using Webshop.Domain.Entities; // Wichtiges using für ApplicationUser
|
using Webshop.Application.Services.Admin.Interfaces;
|
||||||
|
using Webshop.Domain.Entities;
|
||||||
|
using Webshop.Infrastructure.Data; // WICHTIG: Stellt sicher, dass ApplicationDbContext gefunden wird.
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
{
|
{
|
||||||
|
// --- SCHRITT 1: Die fehlende Klassendeklaration ---
|
||||||
public class AdminUserService : IAdminUserService
|
public class AdminUserService : IAdminUserService
|
||||||
{
|
{
|
||||||
// Wir verwenden nun den UserManager mit unserer neuen ApplicationUser-Klasse
|
// --- SCHRITT 2: Die fehlenden Feld-Deklarationen ---
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public AdminUserService(UserManager<ApplicationUser> userManager)
|
// --- SCHRITT 3: Der Konstruktor, der die Felder zuweist ---
|
||||||
|
public AdminUserService(UserManager<ApplicationUser> userManager, ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- AB HIER: Alle Ihre Methoden, unverändert ---
|
||||||
public async Task<IEnumerable<UserDto>> GetAllUsersAsync()
|
public async Task<IEnumerable<UserDto>> GetAllUsersAsync()
|
||||||
{
|
{
|
||||||
// Alle Benutzer aus der Datenbank laden
|
var users = await _userManager.Users
|
||||||
var users = await _userManager.Users.ToListAsync();
|
.Include(u => u.Customer)
|
||||||
var userDtos = new List<UserDto>();
|
.ToListAsync();
|
||||||
|
|
||||||
// Für jeden Benutzer ein DTO erstellen und die Daten mappen
|
var userDtos = new List<UserDto>();
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
userDtos.Add(new UserDto
|
userDtos.Add(new UserDto
|
||||||
@@ -33,24 +40,28 @@ namespace Webshop.Application.Services.Admin
|
|||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
Email = user.Email ?? string.Empty,
|
Email = user.Email ?? string.Empty,
|
||||||
UserName = user.UserName ?? string.Empty,
|
UserName = user.UserName ?? string.Empty,
|
||||||
CreatedDate = user.CreatedDate, // Dieses Feld ist jetzt verfügbar!
|
CreatedDate = user.CreatedDate,
|
||||||
EmailConfirmed = user.EmailConfirmed,
|
EmailConfirmed = user.EmailConfirmed,
|
||||||
Roles = (await _userManager.GetRolesAsync(user)).ToList() // Rollen des Benutzers abrufen
|
Roles = (await _userManager.GetRolesAsync(user)).ToList(),
|
||||||
|
LastActive = user.LastActive,
|
||||||
|
FirstName = user.Customer?.FirstName ?? string.Empty,
|
||||||
|
LastName = user.Customer?.LastName ?? string.Empty
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return userDtos;
|
return userDtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<UserDto?> GetUserByIdAsync(string userId)
|
public async Task<UserDto?> GetUserByIdAsync(string userId)
|
||||||
{
|
{
|
||||||
var user = await _userManager.FindByIdAsync(userId);
|
var user = await _userManager.Users
|
||||||
|
.Include(u => u.Customer)
|
||||||
|
.FirstOrDefaultAsync(u => u.Id == userId);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Den gefundenen Benutzer in ein DTO umwandeln
|
|
||||||
return new UserDto
|
return new UserDto
|
||||||
{
|
{
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
@@ -58,8 +69,60 @@ namespace Webshop.Application.Services.Admin
|
|||||||
UserName = user.UserName ?? string.Empty,
|
UserName = user.UserName ?? string.Empty,
|
||||||
CreatedDate = user.CreatedDate,
|
CreatedDate = user.CreatedDate,
|
||||||
EmailConfirmed = user.EmailConfirmed,
|
EmailConfirmed = user.EmailConfirmed,
|
||||||
Roles = (await _userManager.GetRolesAsync(user)).ToList()
|
Roles = (await _userManager.GetRolesAsync(user)).ToList(),
|
||||||
|
LastActive = user.LastActive,
|
||||||
|
FirstName = user.Customer?.FirstName ?? string.Empty,
|
||||||
|
LastName = user.Customer?.LastName ?? string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateUserRolesAsync(string userId, List<string> newRoles)
|
||||||
|
{
|
||||||
|
var user = await _userManager.FindByIdAsync(userId);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var existingRoles = await _userManager.GetRolesAsync(user);
|
||||||
|
var removeResult = await _userManager.RemoveFromRolesAsync(user, existingRoles);
|
||||||
|
if (!removeResult.Succeeded)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var addResult = await _userManager.AddToRolesAsync(user, newRoles);
|
||||||
|
return addResult.Succeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> DeleteUserAsync(string userId)
|
||||||
|
{
|
||||||
|
var user = await _userManager.FindByIdAsync(userId);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kaskadierendes Löschen der abhängigen Daten
|
||||||
|
var customer = await _context.Customers
|
||||||
|
.Include(c => c.Orders)
|
||||||
|
.Include(c => c.Reviews)
|
||||||
|
.Include(c => c.Addresses)
|
||||||
|
.FirstOrDefaultAsync(c => c.AspNetUserId == userId);
|
||||||
|
|
||||||
|
if (customer != null)
|
||||||
|
{
|
||||||
|
_context.Reviews.RemoveRange(customer.Reviews);
|
||||||
|
_context.Orders.RemoveRange(customer.Orders);
|
||||||
|
_context.Addresses.RemoveRange(customer.Addresses);
|
||||||
|
_context.Customers.Remove(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zum Schluss den Identity-Benutzer löschen
|
||||||
|
var result = await _userManager.DeleteAsync(user);
|
||||||
|
return result.Succeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // <-- Schließende Klammer für die Klasse
|
||||||
|
} // <-- Schließende Klammer für den Namespace
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// src/Webshop.Application/Services/Admin/IAdminUserService.cs
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs.Users; // UserDto
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
|
||||||
{
|
|
||||||
public interface IAdminUserService
|
|
||||||
{
|
|
||||||
Task<IEnumerable<UserDto>> GetAllUsersAsync();
|
|
||||||
Task<UserDto?> GetUserByIdAsync(string userId);
|
|
||||||
// Task<bool> UpdateUserRolesAsync(string userId, List<string> newRoles); // Beispiel für zukünftige Methode
|
|
||||||
// Task<bool> DeleteUserAsync(string userId); // Beispiel für zukünftige Methode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminCategoryService
|
public interface IAdminCategoryService
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminDiscountService
|
public interface IAdminDiscountService
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminOrderService
|
public interface IAdminOrderService
|
||||||
{
|
{
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// src/Webshop.Application/Services/Admin/IAdminProductService.cs
|
// src/Webshop.Application/Services/Admin/IAdminProductService.cs
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs; // AdminProductDto
|
using Webshop.Application.DTOs.Products;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminProductService
|
public interface IAdminProductService
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminSettingService
|
public interface IAdminSettingService
|
||||||
{
|
{
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
using System; // Für Guid
|
using System; // Für Guid
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs; // Für SupplierDto
|
using Webshop.Application.DTOs.Suppliers;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAdminSupplierService
|
public interface IAdminSupplierService
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Admin.Interfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Definiert den Vertrag für den Dienst zur Verwaltung von Benutzern durch einen Admin.
|
||||||
|
/// </summary>
|
||||||
|
public interface IAdminUserService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ruft eine Liste aller Benutzer mit ihren zugehörigen Daten ab.
|
||||||
|
/// </summary>
|
||||||
|
Task<IEnumerable<UserDto>> GetAllUsersAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ruft einen einzelnen Benutzer anhand seiner ID ab.
|
||||||
|
/// </summary>
|
||||||
|
Task<UserDto?> GetUserByIdAsync(string userId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aktualisiert die Rollen eines bestimmten Benutzers.
|
||||||
|
/// </summary>
|
||||||
|
Task<bool> UpdateUserRolesAsync(string userId, List<string> newRoles);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Löscht einen Benutzer und alle seine abhängigen Daten (Kundenprofil, Bestellungen etc.).
|
||||||
|
/// </summary>
|
||||||
|
Task<bool> DeleteUserAsync(string userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
// src/Webshop.Application/Services/Auth/AuthService.cs
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
using System.Threading.Tasks;
|
using Webshop.Domain.Entities;
|
||||||
using System.Collections.Generic;
|
using Webshop.Infrastructure.Data;
|
||||||
using Webshop.Domain.Entities; // <-- WICHTIG: Das Using für Ihre neue Klasse hinzufügen
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Auth
|
namespace Webshop.Application.Services.Auth
|
||||||
{
|
{
|
||||||
public class AuthService : IAuthService
|
public class AuthService : IAuthService
|
||||||
{
|
{
|
||||||
// Ändern Sie hier IdentityUser zu ApplicationUser
|
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly RoleManager<IdentityRole> _roleManager;
|
private readonly RoleManager<IdentityRole> _roleManager;
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public AuthService(
|
public AuthService(
|
||||||
// Ändern Sie auch hier die Typen im Konstruktor
|
|
||||||
UserManager<ApplicationUser> userManager,
|
UserManager<ApplicationUser> userManager,
|
||||||
SignInManager<ApplicationUser> signInManager,
|
SignInManager<ApplicationUser> signInManager,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
RoleManager<IdentityRole> roleManager)
|
RoleManager<IdentityRole> roleManager,
|
||||||
|
ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_signInManager = signInManager;
|
_signInManager = signInManager;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_roleManager = roleManager;
|
_roleManager = roleManager;
|
||||||
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request)
|
public async Task<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request)
|
||||||
@@ -41,12 +41,11 @@ namespace Webshop.Application.Services.Auth
|
|||||||
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "E-Mail ist bereits registriert." };
|
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "E-Mail ist bereits registriert." };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstellen Sie hier eine Instanz Ihrer neuen ApplicationUser-Klasse
|
|
||||||
var user = new ApplicationUser
|
var user = new ApplicationUser
|
||||||
{
|
{
|
||||||
Email = request.Email,
|
Email = request.Email,
|
||||||
UserName = request.Email,
|
UserName = request.Email,
|
||||||
CreatedDate = DateTimeOffset.UtcNow // Setzen Sie das neue Feld!
|
CreatedDate = DateTimeOffset.UtcNow
|
||||||
};
|
};
|
||||||
var result = await _userManager.CreateAsync(user, request.Password);
|
var result = await _userManager.CreateAsync(user, request.Password);
|
||||||
|
|
||||||
@@ -56,7 +55,17 @@ namespace Webshop.Application.Services.Auth
|
|||||||
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = errors };
|
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = errors };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Der Rest der Logik bleibt gleich, da die Rollenverwaltung nicht vom User-Typ abhängt
|
// Zugehöriges kaufmännisches Kundenprofil erstellen
|
||||||
|
var customer = new Customer
|
||||||
|
{
|
||||||
|
AspNetUserId = user.Id,
|
||||||
|
FirstName = request.FirstName,
|
||||||
|
LastName = request.LastName
|
||||||
|
};
|
||||||
|
_context.Customers.Add(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Dem Benutzer die "Customer"-Rolle zuweisen
|
||||||
if (!await _roleManager.RoleExistsAsync("Customer"))
|
if (!await _roleManager.RoleExistsAsync("Customer"))
|
||||||
{
|
{
|
||||||
await _roleManager.CreateAsync(new IdentityRole("Customer"));
|
await _roleManager.CreateAsync(new IdentityRole("Customer"));
|
||||||
@@ -78,7 +87,6 @@ namespace Webshop.Application.Services.Auth
|
|||||||
|
|
||||||
public async Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request)
|
public async Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request)
|
||||||
{
|
{
|
||||||
// Diese Methode funktioniert ohne Änderungen, da der _userManager jetzt vom richtigen Typ ist.
|
|
||||||
var user = await _userManager.FindByEmailAsync(request.Email);
|
var user = await _userManager.FindByEmailAsync(request.Email);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@@ -91,6 +99,10 @@ namespace Webshop.Application.Services.Auth
|
|||||||
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "Ungültige Anmeldeinformationen." };
|
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "Ungültige Anmeldeinformationen." };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zeitstempel für "Zuletzt aktiv" aktualisieren
|
||||||
|
user.LastActive = DateTimeOffset.UtcNow;
|
||||||
|
await _userManager.UpdateAsync(user);
|
||||||
|
|
||||||
var roles = await _userManager.GetRolesAsync(user);
|
var roles = await _userManager.GetRolesAsync(user);
|
||||||
var token = await GenerateJwtToken(user, roles);
|
var token = await GenerateJwtToken(user, roles);
|
||||||
|
|
||||||
@@ -106,7 +118,6 @@ namespace Webshop.Application.Services.Auth
|
|||||||
|
|
||||||
public async Task<AuthResponseDto> LoginAdminAsync(LoginRequestDto request)
|
public async Task<AuthResponseDto> LoginAdminAsync(LoginRequestDto request)
|
||||||
{
|
{
|
||||||
// Diese Methode profitiert direkt von der Korrektur in LoginUserAsync.
|
|
||||||
var authResponse = await LoginUserAsync(request);
|
var authResponse = await LoginUserAsync(request);
|
||||||
if (!authResponse.IsAuthSuccessful)
|
if (!authResponse.IsAuthSuccessful)
|
||||||
{
|
{
|
||||||
@@ -114,7 +125,6 @@ namespace Webshop.Application.Services.Auth
|
|||||||
}
|
}
|
||||||
|
|
||||||
var user = await _userManager.FindByEmailAsync(request.Email);
|
var user = await _userManager.FindByEmailAsync(request.Email);
|
||||||
// Stellt sicher, dass der User gefunden wurde und die Rolle "Admin" hat.
|
|
||||||
if (user == null || !await _userManager.IsInRoleAsync(user, "Admin"))
|
if (user == null || !await _userManager.IsInRoleAsync(user, "Admin"))
|
||||||
{
|
{
|
||||||
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "Keine Berechtigung." };
|
return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = "Keine Berechtigung." };
|
||||||
@@ -123,7 +133,6 @@ namespace Webshop.Application.Services.Auth
|
|||||||
return authResponse;
|
return authResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ändern Sie hier den Parameter-Typ zu ApplicationUser
|
|
||||||
private async Task<string> GenerateJwtToken(ApplicationUser user, IList<string> roles)
|
private async Task<string> GenerateJwtToken(ApplicationUser user, IList<string> roles)
|
||||||
{
|
{
|
||||||
var claims = new List<Claim>
|
var claims = new List<Claim>
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
// src/Webshop.Application/Services/Auth/IAuthService.cs
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
using System.Threading.Tasks; // Sicherstellen, dass für Task vorhanden
|
|
||||||
using System.Collections.Generic; // Sicherstellen, dass für IList<string> vorhanden
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Auth
|
namespace Webshop.Application.Services.Auth
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Definiert den Vertrag für den Authentifizierungsdienst.
|
||||||
|
/// </summary>
|
||||||
public interface IAuthService
|
public interface IAuthService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Registriert einen neuen Benutzer und erstellt ein zugehöriges Kundenprofil.
|
||||||
|
/// </summary>
|
||||||
Task<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request);
|
Task<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Meldet einen Benutzer an und gibt einen JWT zurück.
|
||||||
|
/// </summary>
|
||||||
Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request);
|
Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Meldet einen Benutzer an und überprüft, ob er die Admin-Rolle hat.
|
||||||
|
/// </summary>
|
||||||
Task<AuthResponseDto> LoginAdminAsync(LoginRequestDto request);
|
Task<AuthResponseDto> LoginAdminAsync(LoginRequestDto request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
|
||||||
{
|
|
||||||
public class CustomerService : ICustomerService
|
|
||||||
{
|
|
||||||
// Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories)
|
|
||||||
|
|
||||||
// public CustomerService(IYourRepository repository) { }
|
|
||||||
|
|
||||||
// Fügen Sie hier Service-Methoden hinzu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Application.DTOs.Auth;
|
|
||||||
using Webshop.Application.DTOs.Users;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
|
||||||
{
|
|
||||||
public interface ICustomerService
|
|
||||||
{
|
|
||||||
// Fügen Sie hier Methodensignaturen hinzu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Customers.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers
|
||||||
{
|
{
|
||||||
public class CheckoutService : ICheckoutService
|
public class CheckoutService : ICheckoutService
|
||||||
{
|
{
|
||||||
52
Webshop.Application/Services/Customers/CustomerService.cs
Normal file
52
Webshop.Application/Services/Customers/CustomerService.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Customers;
|
||||||
|
using Webshop.Application.Services.Customers.Interfaces;
|
||||||
|
using Webshop.Domain.Interfaces; // Wichtig für ICustomerRepository
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Customers
|
||||||
|
{
|
||||||
|
public class CustomerService : ICustomerService
|
||||||
|
{
|
||||||
|
private readonly ICustomerRepository _customerRepository;
|
||||||
|
|
||||||
|
public CustomerService(ICustomerRepository customerRepository)
|
||||||
|
{
|
||||||
|
_customerRepository = customerRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<CustomerDto?> GetMyProfileAsync(string userId)
|
||||||
|
{
|
||||||
|
var customer = await _customerRepository.GetByUserIdAsync(userId);
|
||||||
|
if (customer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mappe die Entity auf das CustomerDto
|
||||||
|
return new CustomerDto
|
||||||
|
{
|
||||||
|
Id = customer.Id,
|
||||||
|
UserId = customer.AspNetUserId,
|
||||||
|
FirstName = customer.FirstName,
|
||||||
|
LastName = customer.LastName,
|
||||||
|
// Fügen Sie hier weitere Felder hinzu, die der Kunde sehen soll (Email, Phone etc.)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateMyProfileAsync(string userId, UpdateCustomerProfileDto profileDto)
|
||||||
|
{
|
||||||
|
var customer = await _customerRepository.GetByUserIdAsync(userId);
|
||||||
|
if (customer == null)
|
||||||
|
{
|
||||||
|
return false; // Kunde nicht gefunden
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktualisiere die Felder
|
||||||
|
customer.FirstName = profileDto.FirstName;
|
||||||
|
customer.LastName = profileDto.LastName;
|
||||||
|
|
||||||
|
await _customerRepository.UpdateAsync(customer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers.Interfaces
|
||||||
{
|
{
|
||||||
public interface ICheckoutService
|
public interface ICheckoutService
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.Customers; // Korrektes Using für DTOs
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Customers.Interfaces
|
||||||
|
{
|
||||||
|
public interface ICustomerService
|
||||||
|
{
|
||||||
|
Task<CustomerDto?> GetMyProfileAsync(string userId);
|
||||||
|
Task<bool> UpdateMyProfileAsync(string userId, UpdateCustomerProfileDto profileDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers.Interfaces
|
||||||
{
|
{
|
||||||
public interface IOrderService
|
public interface IOrderService
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers.Interfaces
|
||||||
{
|
{
|
||||||
public interface IReviewService
|
public interface IReviewService
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Customers.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers
|
||||||
{
|
{
|
||||||
public class OrderService : IOrderService
|
public class OrderService : IOrderService
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Customers.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Customer
|
namespace Webshop.Application.Services.Customers
|
||||||
{
|
{
|
||||||
public class ReviewService : IReviewService
|
public class ReviewService : IReviewService
|
||||||
{
|
{
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.Services.Public.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Webshop.Application.DTOs.Auth;
|
|||||||
using Webshop.Application.DTOs.Users;
|
using Webshop.Application.DTOs.Users;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public.Interfaces
|
||||||
{
|
{
|
||||||
public interface ICategoryService
|
public interface ICategoryService
|
||||||
{
|
{
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// src/Webshop.Application/Services/Public/IProductService.cs
|
// src/Webshop.Application/Services/Public/IProductService.cs
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs; // ProductDto
|
using Webshop.Application.DTOs.Products;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public.Interfaces
|
||||||
{
|
{
|
||||||
public interface IProductService
|
public interface IProductService
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs;
|
|
||||||
using Webshop.Domain.Interfaces;
|
using Webshop.Domain.Interfaces;
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
|
using Webshop.Application.DTOs.Products;
|
||||||
|
using Webshop.Application.Services.Public.Interfaces;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
@@ -8,25 +7,19 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.13.0" />
|
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.13.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.0.18" />
|
||||||
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.18" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Webshop.Domain\Webshop.Domain.csproj" />
|
<ProjectReference Include="..\Webshop.Domain\Webshop.Domain.csproj" />
|
||||||
|
<ProjectReference Include="..\Webshop.Infrastructure\Webshop.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Services\Customer\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,22 +1,13 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Webshop.Domain.Entities
|
namespace Webshop.Domain.Entities
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Erweitert die Standard-Identity-Klasse, um anwendungsspezifische
|
|
||||||
/// Eigenschaften für einen Benutzer zu speichern.
|
|
||||||
/// </summary>
|
|
||||||
public class ApplicationUser : IdentityUser
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
// Hinzugefügtes Feld, das in der Standard-IdentityUser-Klasse fehlt.
|
|
||||||
// Wird benötigt, um die Anforderung Ihrer UserDto zu erfüllen.
|
|
||||||
public DateTimeOffset CreatedDate { get; set; }
|
public DateTimeOffset CreatedDate { get; set; }
|
||||||
|
public DateTimeOffset? LastActive { get; set; }
|
||||||
// BEISPIELE FÜR WEITERE NÜTZLICHE FELDER (können bei Bedarf einkommentiert werden):
|
public virtual Customer Customer { get; set; }
|
||||||
// public string? FirstName { get; set; }
|
|
||||||
// public string? LastName { get; set; }
|
|
||||||
// public byte[]? ProfilePicture { get; set; }
|
|
||||||
// public DateTimeOffset? LastLoginDate { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,50 +1,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Webshop.Domain.Entities;
|
namespace Webshop.Domain.Entities
|
||||||
|
{
|
||||||
/// <summary>
|
|
||||||
/// Für registrierte Nutzer des Webshops. Dies ist die Schnittstelle zu ASP.NET Core Identity.
|
|
||||||
/// </summary>
|
|
||||||
public class Customer
|
public class Customer
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
// Unique-Constraint und Foreign Key werden via Fluent API konfiguriert
|
|
||||||
[Required]
|
[Required]
|
||||||
[MaxLength(450)]
|
|
||||||
public string AspNetUserId { get; set; }
|
public string AspNetUserId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[MaxLength(100)]
|
[MaxLength(100)]
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[MaxLength(100)]
|
[MaxLength(100)]
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
|
|
||||||
// Unique-Constraint wird von Identity verwaltet
|
public virtual ApplicationUser User { get; set; }
|
||||||
[Required]
|
|
||||||
[MaxLength(256)]
|
|
||||||
[EmailAddress]
|
|
||||||
public string Email { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(20)]
|
|
||||||
[Phone]
|
|
||||||
public string? PhoneNumber { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTimeOffset CreatedDate { get; set; }
|
|
||||||
|
|
||||||
public DateTimeOffset? LastLoginDate { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public bool IsActive { get; set; }
|
|
||||||
|
|
||||||
// Navigation Properties
|
|
||||||
public virtual ICollection<Address> Addresses { get; set; } = new List<Address>();
|
public virtual ICollection<Address> Addresses { get; set; } = new List<Address>();
|
||||||
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||||
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Domain.Interfaces
|
namespace Webshop.Domain.Interfaces
|
||||||
{
|
{
|
||||||
public interface ICustomerRepository
|
public interface ICustomerRepository
|
||||||
{
|
{
|
||||||
// Fügen Sie hier Methodensignaturen hinzu
|
Task<Customer?> GetByUserIdAsync(string userId);
|
||||||
|
Task UpdateAsync(Customer customer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.18" />
|
||||||
<!-- Die Version kann leicht abweichen -->
|
<!-- Die Version kann leicht abweichen -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,819 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Webshop.Infrastructure.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitalCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Categories",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
|
||||||
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
ParentCategoryId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
DisplayOrder = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Categories_Categories_ParentCategoryId",
|
|
||||||
column: x => x.ParentCategoryId,
|
|
||||||
principalTable: "Categories",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Customers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
AspNetUserId = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
|
|
||||||
FirstName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
LastName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
||||||
PhoneNumber = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
|
||||||
CreatedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
LastLoginDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Customers", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Discounts",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
DiscountType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
DiscountValue = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
StartDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
EndDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
RequiresCouponCode = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
CouponCode = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
||||||
MinimumOrderAmount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
MaximumUsageCount = table.Column<int>(type: "integer", nullable: true),
|
|
||||||
CurrentUsageCount = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Discounts", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PaymentMethods",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
PaymentGatewayType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
ProcessingFee = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PaymentMethods", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Roles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Settings",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Key = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
Value = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
|
||||||
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
Group = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Settings", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ShippingMethods",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
||||||
BaseCost = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
MinimumOrderAmount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
EstimatedDeliveryTime = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
|
||||||
RequiresTracking = table.Column<bool>(type: "boolean", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ShippingMethods", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Users",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "text", nullable: false),
|
|
||||||
CreatedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
PasswordHash = table.Column<string>(type: "text", nullable: true),
|
|
||||||
SecurityStamp = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "text", nullable: true),
|
|
||||||
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Users", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Addresses",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
AddressType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
||||||
Street = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
Street2 = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
|
||||||
City = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
State = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
|
||||||
PostalCode = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
||||||
Country = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
CompanyName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
|
||||||
FirstName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
LastName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Addresses", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Addresses_Customers_CustomerId",
|
|
||||||
column: x => x.CustomerId,
|
|
||||||
principalTable: "Customers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CategoryDiscounts",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
DiscountId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CategoryDiscounts_Categories_CategoryId",
|
|
||||||
column: x => x.CategoryId,
|
|
||||||
principalTable: "Categories",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CategoryDiscounts_Discounts_DiscountId",
|
|
||||||
column: x => x.DiscountId,
|
|
||||||
principalTable: "Discounts",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "RoleClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
RoleId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_RoleClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_RoleClaims_Roles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "Roles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserClaims_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserLogins",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ProviderKey = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserLogins_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
RoleId = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserRoles_Roles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "Roles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserRoles_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserTokens",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Value = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserTokens_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
OrderNumber = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
GuestEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
GuestPhoneNumber = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
|
||||||
OrderDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
OrderStatus = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
OrderTotal = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
ShippingCost = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
TaxAmount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
DiscountAmount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
PaymentStatus = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
PaymentMethod = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
PaymentMethodId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
ShippingMethodId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
TransactionId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
|
||||||
BillingAddressId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
ShippingAddressId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
CustomerNotes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
|
||||||
AdminNotes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Addresses_BillingAddressId",
|
|
||||||
column: x => x.BillingAddressId,
|
|
||||||
principalTable: "Addresses",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Addresses_ShippingAddressId",
|
|
||||||
column: x => x.ShippingAddressId,
|
|
||||||
principalTable: "Addresses",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Customers_CustomerId",
|
|
||||||
column: x => x.CustomerId,
|
|
||||||
principalTable: "Customers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_PaymentMethods_PaymentMethodId",
|
|
||||||
column: x => x.PaymentMethodId,
|
|
||||||
principalTable: "PaymentMethods",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_ShippingMethods_ShippingMethodId",
|
|
||||||
column: x => x.ShippingMethodId,
|
|
||||||
principalTable: "ShippingMethods",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Suppliers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
ContactPerson = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
|
||||||
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
||||||
AddressId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
Notes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Suppliers", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Suppliers_Addresses_AddressId",
|
|
||||||
column: x => x.AddressId,
|
|
||||||
principalTable: "Addresses",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Products",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "character varying(4000)", maxLength: 4000, nullable: true),
|
|
||||||
ShortDescription = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
||||||
SKU = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
Price = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
OldPrice = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
IsInStock = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
StockQuantity = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Weight = table.Column<decimal>(type: "numeric(18,3)", precision: 18, scale: 3, nullable: true),
|
|
||||||
Width = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
Height = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
Length = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
||||||
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
|
||||||
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
CreatedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
LastModifiedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
SupplierId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
PurchasePrice = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Products", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Products_Suppliers_SupplierId",
|
|
||||||
column: x => x.SupplierId,
|
|
||||||
principalTable: "Suppliers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ProductCategories",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
CategoryId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ProductCategories", x => new { x.ProductId, x.CategoryId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ProductCategories_Categories_CategoryId",
|
|
||||||
column: x => x.CategoryId,
|
|
||||||
principalTable: "Categories",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ProductCategories_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ProductDiscounts",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
DiscountId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ProductDiscounts", x => new { x.ProductId, x.DiscountId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ProductDiscounts_Discounts_DiscountId",
|
|
||||||
column: x => x.DiscountId,
|
|
||||||
principalTable: "Discounts",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ProductDiscounts_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ProductVariants",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
Value = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
||||||
SKU = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
||||||
PriceAdjustment = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
StockQuantity = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ProductVariants", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ProductVariants_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Reviews",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
Rating = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Title = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
|
||||||
Comment = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
|
||||||
ReviewDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
IsApproved = table.Column<bool>(type: "boolean", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Reviews", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Reviews_Customers_CustomerId",
|
|
||||||
column: x => x.CustomerId,
|
|
||||||
principalTable: "Customers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Reviews_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "OrderItems",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
OrderId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
ProductVariantId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
ProductName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
||||||
ProductSKU = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
||||||
Quantity = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
UnitPrice = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
||||||
TotalPrice = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OrderItems", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OrderItems_Orders_OrderId",
|
|
||||||
column: x => x.OrderId,
|
|
||||||
principalTable: "Orders",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OrderItems_ProductVariants_ProductVariantId",
|
|
||||||
column: x => x.ProductVariantId,
|
|
||||||
principalTable: "ProductVariants",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.SetNull);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OrderItems_Products_ProductId",
|
|
||||||
column: x => x.ProductId,
|
|
||||||
principalTable: "Products",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.SetNull);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Addresses_CustomerId",
|
|
||||||
table: "Addresses",
|
|
||||||
column: "CustomerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Categories_ParentCategoryId",
|
|
||||||
table: "Categories",
|
|
||||||
column: "ParentCategoryId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Categories_Slug",
|
|
||||||
table: "Categories",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_CategoryDiscounts_DiscountId",
|
|
||||||
table: "CategoryDiscounts",
|
|
||||||
column: "DiscountId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Discounts_CouponCode",
|
|
||||||
table: "Discounts",
|
|
||||||
column: "CouponCode",
|
|
||||||
unique: true,
|
|
||||||
filter: "\"CouponCode\" IS NOT NULL");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OrderItems_OrderId",
|
|
||||||
table: "OrderItems",
|
|
||||||
column: "OrderId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OrderItems_ProductId",
|
|
||||||
table: "OrderItems",
|
|
||||||
column: "ProductId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OrderItems_ProductVariantId",
|
|
||||||
table: "OrderItems",
|
|
||||||
column: "ProductVariantId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_BillingAddressId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "BillingAddressId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_CustomerId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "CustomerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_OrderNumber",
|
|
||||||
table: "Orders",
|
|
||||||
column: "OrderNumber",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_PaymentMethodId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "PaymentMethodId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ShippingAddressId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ShippingAddressId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ShippingMethodId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ShippingMethodId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ProductCategories_CategoryId",
|
|
||||||
table: "ProductCategories",
|
|
||||||
column: "CategoryId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ProductDiscounts_DiscountId",
|
|
||||||
table: "ProductDiscounts",
|
|
||||||
column: "DiscountId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Products_SKU",
|
|
||||||
table: "Products",
|
|
||||||
column: "SKU",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Products_Slug",
|
|
||||||
table: "Products",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Products_SupplierId",
|
|
||||||
table: "Products",
|
|
||||||
column: "SupplierId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ProductVariants_ProductId",
|
|
||||||
table: "ProductVariants",
|
|
||||||
column: "ProductId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Reviews_CustomerId",
|
|
||||||
table: "Reviews",
|
|
||||||
column: "CustomerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Reviews_ProductId",
|
|
||||||
table: "Reviews",
|
|
||||||
column: "ProductId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_RoleClaims_RoleId",
|
|
||||||
table: "RoleClaims",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "RoleNameIndex",
|
|
||||||
table: "Roles",
|
|
||||||
column: "NormalizedName",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Settings_Key",
|
|
||||||
table: "Settings",
|
|
||||||
column: "Key",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Suppliers_AddressId",
|
|
||||||
table: "Suppliers",
|
|
||||||
column: "AddressId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserClaims_UserId",
|
|
||||||
table: "UserClaims",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserLogins_UserId",
|
|
||||||
table: "UserLogins",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserRoles_RoleId",
|
|
||||||
table: "UserRoles",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "Users",
|
|
||||||
column: "NormalizedEmail");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "Users",
|
|
||||||
column: "NormalizedUserName",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CategoryDiscounts");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "OrderItems");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ProductCategories");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ProductDiscounts");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Reviews");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "RoleClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Settings");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserLogins");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserTokens");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ProductVariants");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Categories");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Discounts");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Roles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PaymentMethods");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ShippingMethods");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Suppliers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Addresses");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Customers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,8 @@
|
|||||||
// Auto-generiert von CreateWebshopFiles.ps1
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
using Webshop.Domain.Interfaces;
|
using Webshop.Domain.Interfaces;
|
||||||
using Webshop.Infrastructure.Data;
|
using Webshop.Infrastructure.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Webshop.Infrastructure.Repositories
|
namespace Webshop.Infrastructure.Repositories
|
||||||
@@ -18,12 +16,15 @@ namespace Webshop.Infrastructure.Repositories
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fügen Sie hier Repository-Methoden hinzu
|
public async Task<Customer?> GetByUserIdAsync(string userId)
|
||||||
// Beispiel:
|
{
|
||||||
// public async Task<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
return await _context.Customers.FirstOrDefaultAsync(c => c.AspNetUserId == userId);
|
||||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
}
|
||||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
|
||||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
public async Task UpdateAsync(Customer customer)
|
||||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
{
|
||||||
|
_context.Customers.Update(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user