From ce69373adb9153a647a892b44bd1474983c99134 Mon Sep 17 00:00:00 2001 From: "Tizian.Breuch" Date: Wed, 23 Jul 2025 21:08:30 +0200 Subject: [PATCH] try --- CreateWebshopFiles.ps1 | 939 ++++++++++++++++++ .../Admin/AdminCategoriesController.cs | 18 + .../Admin/AdminDiscountsController.cs | 18 + .../Admin/AdminOrdersController.cs | 18 + .../Admin/AdminProductsController.cs | 26 +- .../Admin/AdminSettingsController.cs | 18 + ...troller.cs => AdminSuppliersController.cs} | 7 +- .../Controllers/Admin/AdminUsersController.cs | 20 +- .../Customer/CheckoutController.cs | 18 + .../Controllers/Customer/OrdersController.cs | 23 +- .../Controllers/Customer/ProfileController.cs | 18 + .../Controllers/Customer/ReviewsController.cs | 18 + .../Public/CategoriesController.cs | 18 + .../Controllers/Public/ProductsController.cs | 31 +- Webshop.Application/DTOs/AddressDto.cs | 20 + Webshop.Application/DTOs/AdminProductDto.cs | 14 +- .../DTOs/Auth/AuthResponseDto.cs | 10 +- .../DTOs/Auth/LoginRequestDto.cs | 9 +- .../DTOs/Auth/RegisterRequestDto.cs | 9 +- Webshop.Application/DTOs/CategoryDto.cs | 20 + Webshop.Application/DTOs/CreateCategoryDto.cs | 19 + Webshop.Application/DTOs/CreateOrderDto.cs | 20 + .../DTOs/CreateOrderItemDto.cs | 15 + Webshop.Application/DTOs/CreateReviewDto.cs | 16 + Webshop.Application/DTOs/CustomerDto.cs | 20 + Webshop.Application/DTOs/DiscountDto.cs | 24 + Webshop.Application/DTOs/OrderDetailDto.cs | 27 + Webshop.Application/DTOs/OrderItemDto.cs | 21 + Webshop.Application/DTOs/OrderSummaryDto.cs | 21 + Webshop.Application/DTOs/PaymentMethodDto.cs | 19 + Webshop.Application/DTOs/ProductDto.cs | 14 +- Webshop.Application/DTOs/ProductVariantDto.cs | 21 + Webshop.Application/DTOs/ReviewDto.cs | 20 + Webshop.Application/DTOs/SettingDto.cs | 16 + Webshop.Application/DTOs/ShippingMethodDto.cs | 19 + Webshop.Application/DTOs/SupplierDto.cs | 13 +- Webshop.Application/DTOs/Users/UserDto.cs | 12 +- .../Services/Admin/AdminCategoryService.cs | 17 + .../Services/Admin/AdminDiscountService.cs | 17 + .../Services/Admin/AdminOrderService.cs | 17 + .../Services/Admin/AdminProductService.cs | 124 +-- .../Services/Admin/AdminSettingService.cs | 17 + .../Services/Admin/AdminSupplierService.cs | 67 +- .../Services/Admin/AdminUserService.cs | 59 +- .../Services/Admin/IAdminCategoryService.cs | 16 + .../Services/Admin/IAdminDiscountService.cs | 16 + .../Services/Admin/IAdminOrderService.cs | 16 + .../Services/Admin/IAdminProductService.cs | 16 + .../Services/Admin/IAdminSettingService.cs | 16 + .../Services/Admin/IAdminSupplierService.cs | 16 + .../Services/Admin/IAdminUserService.cs | 15 + .../Services/Customer/CheckoutService.cs | 17 + .../Services/Customer/CustomerService.cs | 17 + .../Services/Customer/ICheckoutService.cs | 16 + .../Services/Customer/ICustomerService.cs | 16 + .../Services/Customer/IOrderService.cs | 16 + .../Services/Customer/IReviewService.cs | 16 + .../Services/Customer/OrderService.cs | 17 + .../Services/Customer/ReviewService.cs | 17 + .../Services/Public/CategoryService.cs | 17 + .../Services/Public/ICategoryService.cs | 16 + .../Services/Public/IProductService.cs | 14 + .../Services/Public/ProductService.cs | 34 +- .../Interfaces/ICategoryRepository.cs | 14 + .../Interfaces/ICustomerRepository.cs | 14 + .../Interfaces/IDiscountRepository.cs | 14 + Webshop.Domain/Interfaces/IOrderRepository.cs | 14 + .../Interfaces/IPaymentMethodRepository.cs | 14 + .../Interfaces/IProductRepository.cs | 9 +- .../Interfaces/IReviewRepository.cs | 14 + .../Interfaces/ISettingRepository.cs | 14 + .../Interfaces/IShippingMethodRepository.cs | 14 + .../Interfaces/ISupplierRepository.cs | 6 +- ...20250723190813_InititalCreate.Designer.cs} | 4 +- ...te.cs => 20250723190813_InititalCreate.cs} | 2 +- .../Repositories/CategoryRepository.cs | 29 + .../Repositories/CustomerRepository.cs | 29 + .../Repositories/DiscountRepository.cs | 29 + .../Repositories/OrderRepository.cs | 29 + .../Repositories/PaymentMethodRepository.cs | 29 + .../Repositories/ProductRepository.cs | 27 +- .../Repositories/ReviewRepository.cs | 29 + .../Repositories/SettingRepository.cs | 29 + .../Repositories/ShippingMethodRepository.cs | 29 + .../Repositories/SupplierRepository.cs | 20 +- 85 files changed, 2311 insertions(+), 332 deletions(-) create mode 100644 CreateWebshopFiles.ps1 create mode 100644 Webshop.Api/Controllers/Admin/AdminCategoriesController.cs create mode 100644 Webshop.Api/Controllers/Admin/AdminDiscountsController.cs create mode 100644 Webshop.Api/Controllers/Admin/AdminOrdersController.cs create mode 100644 Webshop.Api/Controllers/Admin/AdminSettingsController.cs rename Webshop.Api/Controllers/Admin/{HomeController.cs => AdminSuppliersController.cs} (84%) create mode 100644 Webshop.Api/Controllers/Customer/CheckoutController.cs create mode 100644 Webshop.Api/Controllers/Customer/ProfileController.cs create mode 100644 Webshop.Api/Controllers/Customer/ReviewsController.cs create mode 100644 Webshop.Api/Controllers/Public/CategoriesController.cs create mode 100644 Webshop.Application/DTOs/AddressDto.cs create mode 100644 Webshop.Application/DTOs/CategoryDto.cs create mode 100644 Webshop.Application/DTOs/CreateCategoryDto.cs create mode 100644 Webshop.Application/DTOs/CreateOrderDto.cs create mode 100644 Webshop.Application/DTOs/CreateOrderItemDto.cs create mode 100644 Webshop.Application/DTOs/CreateReviewDto.cs create mode 100644 Webshop.Application/DTOs/CustomerDto.cs create mode 100644 Webshop.Application/DTOs/DiscountDto.cs create mode 100644 Webshop.Application/DTOs/OrderDetailDto.cs create mode 100644 Webshop.Application/DTOs/OrderItemDto.cs create mode 100644 Webshop.Application/DTOs/OrderSummaryDto.cs create mode 100644 Webshop.Application/DTOs/PaymentMethodDto.cs create mode 100644 Webshop.Application/DTOs/ProductVariantDto.cs create mode 100644 Webshop.Application/DTOs/ReviewDto.cs create mode 100644 Webshop.Application/DTOs/SettingDto.cs create mode 100644 Webshop.Application/DTOs/ShippingMethodDto.cs create mode 100644 Webshop.Application/Services/Admin/AdminCategoryService.cs create mode 100644 Webshop.Application/Services/Admin/AdminDiscountService.cs create mode 100644 Webshop.Application/Services/Admin/AdminOrderService.cs create mode 100644 Webshop.Application/Services/Admin/AdminSettingService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminCategoryService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminDiscountService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminOrderService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminProductService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminSettingService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminSupplierService.cs create mode 100644 Webshop.Application/Services/Admin/IAdminUserService.cs create mode 100644 Webshop.Application/Services/Customer/CheckoutService.cs create mode 100644 Webshop.Application/Services/Customer/CustomerService.cs create mode 100644 Webshop.Application/Services/Customer/ICheckoutService.cs create mode 100644 Webshop.Application/Services/Customer/ICustomerService.cs create mode 100644 Webshop.Application/Services/Customer/IOrderService.cs create mode 100644 Webshop.Application/Services/Customer/IReviewService.cs create mode 100644 Webshop.Application/Services/Customer/OrderService.cs create mode 100644 Webshop.Application/Services/Customer/ReviewService.cs create mode 100644 Webshop.Application/Services/Public/CategoryService.cs create mode 100644 Webshop.Application/Services/Public/ICategoryService.cs create mode 100644 Webshop.Application/Services/Public/IProductService.cs create mode 100644 Webshop.Domain/Interfaces/ICategoryRepository.cs create mode 100644 Webshop.Domain/Interfaces/ICustomerRepository.cs create mode 100644 Webshop.Domain/Interfaces/IDiscountRepository.cs create mode 100644 Webshop.Domain/Interfaces/IOrderRepository.cs create mode 100644 Webshop.Domain/Interfaces/IPaymentMethodRepository.cs create mode 100644 Webshop.Domain/Interfaces/IReviewRepository.cs create mode 100644 Webshop.Domain/Interfaces/ISettingRepository.cs create mode 100644 Webshop.Domain/Interfaces/IShippingMethodRepository.cs rename Webshop.Infrastructure/Migrations/{20250723113024_InitialCreate.Designer.cs => 20250723190813_InititalCreate.Designer.cs} (99%) rename Webshop.Infrastructure/Migrations/{20250723113024_InitialCreate.cs => 20250723190813_InititalCreate.cs} (99%) create mode 100644 Webshop.Infrastructure/Repositories/CategoryRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/CustomerRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/DiscountRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/OrderRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/PaymentMethodRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/ReviewRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/SettingRepository.cs create mode 100644 Webshop.Infrastructure/Repositories/ShippingMethodRepository.cs diff --git a/CreateWebshopFiles.ps1 b/CreateWebshopFiles.ps1 new file mode 100644 index 0000000..deed94f --- /dev/null +++ b/CreateWebshopFiles.ps1 @@ -0,0 +1,939 @@ +# Definieren des Basisverzeichnisses der Solution +$solutionRoot = Get-Location + +Write-Host "Starte Dateierstellung im Verzeichnis: $solutionRoot" -ForegroundColor Green + +# --- Hilfsfunktionen --- + +function New-CSharpFile { + param ( + [string]$ProjectName, + [string]$RelativePath, # Pfad relativ zum Projekt (z.B. "Controllers/Admin") + [string]$FileName, + [string]$Type, # "class" oder "interface" + [string]$BaseNamespace # Z.B. "Webshop.Application" + ) + + # Korrigierte Join-Path-Verwendung: Kein "src" hier, da Projekte direkt unter solutionRoot liegen + $projectSpecificDir = Join-Path -Path $solutionRoot -ChildPath $ProjectName + + # Wenn RelativePath leer ist, ist fullDirPath gleich projectSpecificDir + if ([string]::IsNullOrEmpty($RelativePath)) { + $fullDirPath = $projectSpecificDir + } else { + $fullDirPath = Join-Path -Path $projectSpecificDir -ChildPath $RelativePath + } + + $fullFilePath = Join-Path -Path $fullDirPath -ChildPath $FileName + + # Sicherstellen, dass der Zielordner existiert + if (-not (Test-Path $fullDirPath)) { + New-Item -ItemType Directory -Path $fullDirPath -Force | Out-Null + Write-Host "Ordner erstellt: $fullDirPath" -ForegroundColor DarkGray + } + + # Den vollständigen Namespace berechnen (z.B. Webshop.Application.Services.Admin) + $fullNamespace = $BaseNamespace + if (-not [string]::IsNullOrEmpty($RelativePath)) { + $namespaceParts = $RelativePath.Replace('/', '.') + $fullNamespace = "$BaseNamespace.$namespaceParts" + } + + $nameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($FileName) + + $fileContent = "" # Initialisiere als leeren String + + # Standard-Usings, die fast immer benötigt werden + $commonUsings = @" +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +"@ + + # Spezielle Inhalte für Controller + if ($ProjectName -eq "Webshop.Api" -and $RelativePath.StartsWith("Controllers")) { + $controllerSpecificUsings = "" + # Korrektur der Route: Das letzte Segment des RelativePath wird als Basis für den Controller-Namen verwendet + $routeBaseSegment = $RelativePath.Split('/')[-1].ToLower() + # Wenn es sich um einen Top-Level Controller handelt (z.B. AuthController direkt in Controllers, nicht in Unterordner) + # AuthController wird manuell gehandhabt, da die Route `api/v1/[controller]` ist. + # Alle anderen Controller in Unterordnern haben `api/v1/subfolder/[controller]` + if ($routeBaseSegment -eq "controllers") { # Dies sollte eigentlich nicht mehr vorkommen nach der Umstrukturierung + $controllerAttributes = "[ApiController]`n [Route(`"api/v1/[controller]"")]" + } else { + $controllerAttributes = "[ApiController]`n [Route(`"api/v1/$routeBaseSegment/[controller]"")]" + } + + # Autorisierungsattribute + if ($RelativePath -like "*Admin") { + $controllerSpecificUsings += "using Microsoft.AspNetCore.Authorization;`n" + $controllerAttributes += "`n [Authorize(Roles = `"Admin`")]" + } elseif ($RelativePath -like "*Customer") { + $controllerSpecificUsings += "using Microsoft.AspNetCore.Authorization;`n" + $controllerAttributes += "`n [Authorize(Roles = `"Customer`")]" + } elseif ($RelativePath -like "*Public") { + $controllerSpecificUsings += "using Microsoft.AspNetCore.Authorization;`n" + $controllerAttributes += "`n [AllowAnonymous]" + } + + # Bei Auth-Controllern keine Autorisierung als Standard, und Route spezifisch + if ($RelativePath -eq "Controllers/Auth") { + $controllerAttributes = "[ApiController]`n [Route(`"api/v1/[controller]"")]" # Auth-Controller haben oft eine eigene Route + $controllerSpecificUsings += "using Microsoft.AspNetCore.Authorization;`n" # Trotzdem für AllowAnonymous + $controllerSpecificUsings += "using Webshop.Application.DTOs.Auth;`nusing Webshop.Application.Services.Auth;`n" + $controllerContentBody = @" + private readonly IAuthService _authService; + + public AuthController(IAuthService authService) + { + _authService = authService; + } + + [HttpPost(""register"")] + [AllowAnonymous] + public async Task Register([FromBody] RegisterRequestDto request) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + var result = await _authService.RegisterUserAsync(request); + if (!result.IsAuthSuccessful) return BadRequest(new { Message = result.ErrorMessage }); + return Ok(result); + } + + [HttpPost(""login/customer"")] + [AllowAnonymous] + public async Task LoginCustomer([FromBody] LoginRequestDto request) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + var result = await _authService.LoginUserAsync(request); + if (!result.IsAuthSuccessful) return Unauthorized(new { Message = result.ErrorMessage }); + return Ok(result); + } + + [HttpPost(""login/admin"")] + [AllowAnonymous] + public async Task LoginAdmin([FromBody] LoginRequestDto request) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + var result = await _authService.LoginAdminAsync(request); + if (!result.IsAuthSuccessful) return Unauthorized(new { Message = result.ErrorMessage }); + return Ok(result); + } +"@ + } # End AuthController + elseif ($RelativePath -eq "Controllers/Public" -and $nameWithoutExtension -eq "ProductsController") { + $controllerSpecificUsings += "using Webshop.Application.DTOs;`nusing Webshop.Application.Services.Public;`n" + $controllerContentBody = @" + private readonly ProductService _productService; // ServiceName nach Ihrer Konvention beibehalten + + public ProductsController(ProductService productService) + { + _productService = productService; + } + + [HttpGet] + public async Task>> GetAllProducts() + { + var products = await _productService.GetAllProductsAsync(); + return Ok(products); + } +"@ + } # End ProductsController (Public) + elseif ($RelativePath -eq "Controllers/Admin" -and $nameWithoutExtension -eq "AdminProductsController") { + $controllerSpecificUsings += "using Webshop.Application.DTOs;`nusing Webshop.Application.Services.Admin;`n" + $controllerContentBody = @" + private readonly AdminProductService _adminProductService; + + public AdminProductsController(AdminProductService adminProductService) + { + _adminProductService = adminProductService; + } + + [HttpGet] + public async Task>> GetAdminProducts() + { + var products = await _adminProductService.GetAllAdminProductsAsync(); + return Ok(products); + } + + [HttpGet(""{id}"")] + public async Task> GetAdminProduct(Guid id) + { + var product = await _adminProductService.GetAdminProductByIdAsync(id); + if (product == null) return NotFound(); + return Ok(product); + } + + [HttpPost] + public async Task> CreateAdminProduct([FromBody] AdminProductDto productDto) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + var createdProduct = await _adminProductService.CreateAdminProductAsync(productDto); + return CreatedAtAction(nameof(GetAdminProduct), new { id = createdProduct.Id }, createdProduct); + } + + [HttpPut(""{id}"")] + public async Task UpdateAdminProduct(Guid id, [FromBody] AdminProductDto productDto) + { + if (id != productDto.Id) return BadRequest(); + if (!ModelState.IsValid) return BadRequest(ModelState); + var success = await _adminProductService.UpdateAdminProductAsync(productDto); + if (!success) return NotFound(); + return NoContent(); + } + + [HttpDelete(""{id}"")] + public async Task DeleteAdminProduct(Guid id) + { + var success = await _adminProductService.DeleteAdminProductAsync(id); + if (!success) return NotFound(); + return NoContent(); + } +"@ + } # End AdminProductsController + elseif ($RelativePath -eq "Controllers/Admin" -and $nameWithoutExtension -eq "AdminUsersController") { + $controllerSpecificUsings += "using Webshop.Application.DTOs.Users;`nusing Webshop.Application.Services.Admin;`n" + $controllerContentBody = @" + private readonly AdminUserService _adminUserService; + + public AdminUsersController(AdminUserService adminUserService) + { + _adminUserService = adminUserService; + } + + [HttpGet] + public async Task>> GetAllUsers() + { + var users = await _adminUserService.GetAllUsersAsync(); + return Ok(users); + } + + [HttpGet(""{userId}"")] + public async Task> GetUserById(string userId) + { + var user = await _adminUserService.GetUserByIdAsync(userId); + if (user == null) return NotFound(); + return Ok(user); + } +"@ + } # End AdminUsersController + elseif ($RelativePath -eq "Controllers/Admin" -and $nameWithoutExtension -eq "AdminSuppliersController") { + $controllerSpecificUsings += "using Webshop.Application.DTOs;`nusing Webshop.Application.Services.Admin;`n" + $controllerContentBody = @" + private readonly AdminSupplierService _adminSupplierService; + + public AdminSuppliersController(AdminSupplierService adminSupplierService) + { + _adminSupplierService = adminSupplierService; + } + + [HttpGet] + public async Task>> GetAllSuppliers() + { + var suppliers = await _adminSupplierService.GetAllSuppliersAsync(); + return Ok(suppliers); + } + + [HttpPost] + public async Task> CreateSupplier([FromBody] SupplierDto supplierDto) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + var createdSupplier = await _adminSupplierService.CreateSupplierAsync(supplierDto); + return CreatedAtAction(nameof(GetSupplierById), new { id = createdSupplier.Id }, createdSupplier); + } + + [HttpGet(""{id}"")] + public async Task> GetSupplierById(Guid id) + { + var supplier = await _adminSupplierService.GetSupplierByIdAsync(id); + if (supplier == null) return NotFound(); + return Ok(supplier); + } +"@ + } # End AdminSuppliersController + elseif ($RelativePath -eq "Controllers/Customer" -and $nameWithoutExtension -eq "OrdersController") { + $controllerContentBody = @" + [HttpGet(""my-orders"")] + public async Task GetMyOrders() + { + return Ok(new { Message = ""Dies ist Ihr persönlicher Bestellverlauf (Platzhalter)."" }); + } +"@ + } # End OrdersController (Customer) + # Weitere Controller-Inhalte können hier hinzugefügt werden + + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.AspNetCore.Mvc; +$controllerSpecificUsings +$commonUsings + +namespace $fullNamespace +{ + $controllerAttributes + public class $nameWithoutExtension : ControllerBase + { +$controllerContentBody + } +} +"@ + } # Ende Controller Sektion + # Spezielle Inhalte für Repositories (Basiskonstruktor) + elseif ($ProjectName -eq "Webshop.Infrastructure" -and $RelativePath -eq "Repositories" -and $Type -eq "class") { + $interfaceName = "I" + $nameWithoutExtension + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +$commonUsings + +namespace $fullNamespace +{ + public class $nameWithoutExtension : $interfaceName + { + private readonly ApplicationDbContext _context; + + public $nameWithoutExtension(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} +"@ + } # Ende Repositories Sektion + # Spezielle Inhalte für Services (Basiskonstruktor und Interface-Implementierung) + elseif ($ProjectName -eq "Webshop.Application" -and $RelativePath.StartsWith("Services") -and $Type -eq "class") { + $interfaceName = "I" + $nameWithoutExtension + $serviceSpecificUsings = "" + $serviceContentBody = @" + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public $nameWithoutExtension(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu +"@ + + # Abhängigkeiten und spezifischer Content für AuthService + if ($nameWithoutExtension -eq "AuthService") { + $serviceSpecificUsings += "using Microsoft.AspNetCore.Identity;`nusing Microsoft.Extensions.Configuration;`nusing Microsoft.IdentityModel.Tokens;`nusing System.IdentityModel.Tokens.Jwt;`nusing System.Security.Claims;`nusing System.Text;`n" + $serviceSpecificUsings += "using Webshop.Application.DTOs.Auth;`n" + $serviceContentBody = @" + private readonly UserManager _userManager; + private readonly SignInManager _signInManager; + private readonly IConfiguration _configuration; + private readonly RoleManager _roleManager; + + public AuthService( + UserManager userManager, + SignInManager signInManager, + IConfiguration configuration, + RoleManager roleManager) + { + _userManager = userManager; + _signInManager = signInManager; + _configuration = configuration; + _roleManager = roleManager; + } + + // HIER KOMMT DER VORHERIGE AUTHSERVICE CODE HIN (Register, LoginUser, LoginAdmin, GenerateJwtToken) + // DIESER TEIL IST ZU LANG FÜR DIE PS1, ABER WIRD MANUELL EINGEFÜGT. + // Die Methoden Signaturen müssen mit IAuthService übereinstimmen! + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task RegisterUserAsync(RegisterRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; } + public async Task LoginUserAsync(LoginRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; } + public async Task LoginAdminAsync(LoginRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; } + private Task GenerateJwtToken(IdentityUser user, IList roles) { return Task.FromResult(""""); } +"@ + } # End AuthService specific content + + # Abhängigkeiten und spezifischer Content für AdminProductService + elseif ($nameWithoutExtension -eq "AdminProductService") { + $serviceSpecificUsings += "using Webshop.Application.DTOs;`n" # AdminProductDto + $serviceSpecificUsings += "using Webshop.Domain.Entities;`nusing Webshop.Domain.Interfaces;`n" # Entities, IProductRepository + $serviceContentBody = @" + private readonly IProductRepository _productRepository; + + public AdminProductService(IProductRepository productRepository) + { + _productRepository = productRepository; + } + + // HIER KOMMT DER VORHERIGE ADMINPRODUCTSERVICE CODE HIN (GetAllAdminProductsAsync, CreateAdminProductAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllAdminProductsAsync() { return new List(); } + public async Task GetAdminProductByIdAsync(Guid id) { return null; } + public async Task CreateAdminProductAsync(AdminProductDto productDto) { return null; } + public async Task UpdateAdminProductAsync(AdminProductDto productDto) { return false; } + public async Task DeleteAdminProductAsync(Guid id) { return false; } +"@ + } # End AdminProductService specific content + + # Abhängigkeiten und spezifischer Content für AdminUserService + elseif ($nameWithoutExtension -eq "AdminUserService") { + $serviceSpecificUsings += "using Webshop.Application.DTOs.Users;`n" # UserDto + $serviceSpecificUsings += "using Microsoft.AspNetCore.Identity;`nusing Microsoft.EntityFrameworkCore;`n" # UserManager, ToListAsync + $serviceContentBody = @" + private readonly UserManager _userManager; + + public AdminUserService(UserManager userManager) + { + _userManager = userManager; + } + + // HIER KOMMT DER VORHERIGE ADMINUSERSERVICE CODE HIN (GetAllUsersAsync, GetUserByIdAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllUsersAsync() { return new List(); } + public async Task GetUserByIdAsync(string userId) { return null; } +"@ + } # End AdminUserService specific content + + # Abhängigkeiten und spezifischer Content für ProductService (Public) + elseif ($nameWithoutExtension -eq "ProductService" -and $RelativePath -eq "Services/Public") { + $serviceSpecificUsings += "using Webshop.Application.DTOs;`n" # ProductDto + $serviceSpecificUsings += "using Webshop.Domain.Interfaces;`n" # IProductRepository + $serviceSpecificUsings += "using Webshop.Domain.Entities;`n" # Product Entity + $serviceContentBody = @" + private readonly IProductRepository _productRepository; + + public ProductService(IProductRepository productRepository) + { + _productRepository = productRepository; + } + + // HIER KOMMT DER VORHERIGE PRODUCTSERVICE CODE HIN (GetAllProductsAsync, CreateProductAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllProductsAsync() { return new List(); } + public async Task CreateProductAsync(ProductDto productDto) { return null; } +"@ + } # End ProductService specific content + + # Abhängigkeiten und spezifischer Content für AdminSupplierService + elseif ($nameWithoutExtension -eq "AdminSupplierService") { + $serviceSpecificUsings += "using Webshop.Application.DTOs;`n" # SupplierDto + $serviceSpecificUsings += "using Webshop.Domain.Entities;`nusing Webshop.Domain.Interfaces;`n" # Entities, ISupplierRepository + $serviceContentBody = @" + private readonly ISupplierRepository _supplierRepository; + + public AdminSupplierService(ISupplierRepository supplierRepository) + { + _supplierRepository = supplierRepository; + } + + // HIER KOMMT DER VORHERIGE ADMINSUPPLIERSERVICE CODE HIN (GetAllSuppliersAsync, CreateSupplierAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllSuppliersAsync() { return new List(); } + public async Task GetSupplierByIdAsync(Guid id) { return null; } + public async Task CreateSupplierAsync(SupplierDto supplierDto) { return null; } +"@ + } # End AdminSupplierService specific content + + + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +$commonUsings +$serviceSpecificUsings + +namespace $fullNamespace +{ + public class $nameWithoutExtension : $interfaceName + { +$serviceContentBody + } +} +"@ + } # Ende Services Sektion + # Spezielle Inhalte für Interfaces (leere Implementierung) + elseif ($Type -eq "interface") { + $interfaceSpecificUsings = "" + $fileContentBody = "// Fügen Sie hier Methodensignaturen hinzu" # Standard-Inhalt für Interface + if ($ProjectName -eq "Webshop.Domain" -and $RelativePath -eq "Interfaces") { + $interfaceSpecificUsings += "using Webshop.Domain.Entities;`n" + # Beispiel für IProductRepository Methoden + if ($nameWithoutExtension -eq "IProductRepository") { + $fileContentBody = @" + Task GetProductByIdAsync(Guid id); + Task> GetAllProductsAsync(); + Task AddProductAsync(Product product); + Task UpdateProductAsync(Product product); + Task DeleteProductAsync(Guid id); +"@ + } elseif ($nameWithoutExtension -eq "ISupplierRepository") { + $fileContentBody = @" + Task> GetAllSuppliersAsync(); + Task GetSupplierByIdAsync(Guid id); + Task AddSupplierAsync(Supplier supplier); + Task UpdateSupplierAsync(Supplier supplier); + Task DeleteSupplierAsync(Guid id); +"@ + } # Weitere Repository-Interfaces hier + } elseif ($ProjectName -eq "Webshop.Application" -and $RelativePath -like "Services/*") { + $interfaceSpecificUsings += "using Webshop.Application.DTOs;`n" + $interfaceSpecificUsings += "using Webshop.Application.DTOs.Auth;`n" + $interfaceSpecificUsings += "using Webshop.Application.DTOs.Users;`n" + # Beispiel für IAuthService + if ($nameWithoutExtension -eq "IAuthService") { + $fileContentBody = @" + Task RegisterUserAsync(RegisterRequestDto request); + Task LoginUserAsync(LoginRequestDto request); + Task LoginAdminAsync(LoginRequestDto request); +"@ + } + } + + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +$commonUsings +$interfaceSpecificUsings + +namespace $fullNamespace +{ + public interface $nameWithoutExtension + { +$fileContentBody + } +} +"@ + } # Ende Interfaces Sektion + # Spezielle Inhalte für DTOs + elseif ($ProjectName -eq "Webshop.Application" -and $RelativePath.StartsWith("DTOs") -and $Type -eq "class") { + $extraUsings = "" + $properties = @" + public Guid Id { get; set; } = Guid.NewGuid(); + public string Name { get; set; } = string.Empty; + // Fügen Sie hier weitere Eigenschaften hinzu +"@ + if ($nameWithoutExtension -eq "ProductDto") { + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string SKU { get; set; } = string.Empty; + public decimal Price { get; set; } + public bool IsActive { get; set; } + public bool IsInStock { get; set; } + public int StockQuantity { get; set; } + public string? ImageUrl { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "AdminProductDto") { + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string SKU { get; set; } = string.Empty; + public decimal Price { get; set; } + public decimal? OldPrice { get; set; } + public bool IsActive { get; set; } = true; + public bool IsInStock { get; set; } = true; + public int StockQuantity { get; set; } + public decimal? Weight { get; set; } + public string? ImageUrl { get; set; } + public string Slug { get; set; } = string.Empty; + public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.UtcNow; + public DateTimeOffset? LastModifiedDate { get; set; } + public Guid? SupplierId { get; set; } + public decimal? PurchasePrice { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "SupplierDto") { + $properties = @" + public Guid Id { get; set; } = Guid.NewGuid(); + public string Name { get; set; } = string.Empty; + public string? ContactPerson { get; set; } + public string? Email { get; set; } + public string? PhoneNumber { get; set; } + public Guid? AddressId { get; set; } + public string? Notes { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "LoginRequestDto" -or $nameWithoutExtension -eq "RegisterRequestDto") { + $extraUsings += "using System.ComponentModel.DataAnnotations;`n" + if ($nameWithoutExtension -eq "LoginRequestDto") { + $properties = @" + [Required(ErrorMessage = `"E-Mail ist erforderlich.`")] + [EmailAddress(ErrorMessage = `"Ungültiges E-Mail-Format.`")] + public string Email { get; set; } = string.Empty; + + [Required(ErrorMessage = `"Passwort ist erforderlich.`")] + public string Password { get; set; } = string.Empty; +"@ + } elseif ($nameWithoutExtension -eq "RegisterRequestDto") { + $properties = @" + [Required(ErrorMessage = `"E-Mail ist erforderlich.`")] + [EmailAddress(ErrorMessage = `"Ungültiges E-Mail-Format.`")] + public string Email { get; set; } = string.Empty; + + [Required(ErrorMessage = `"Passwort ist erforderlich.`")] + [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; } +"@ + } + } elseif ($nameWithoutExtension -eq "AuthResponseDto") { + $properties = @" + public bool IsAuthSuccessful { get; set; } + public string ErrorMessage { get; set; } = string.Empty; + public string Token { get; set; } = string.Empty; + public string UserId { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public List Roles { get; set; } = new List(); +"@ + } elseif ($nameWithoutExtension -eq "UserDto") { + $properties = @" + public string Id { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string UserName { get; set; } = string.Empty; + public List Roles { get; set; } = new List(); + public DateTimeOffset CreatedDate { get; set; } + public bool EmailConfirmed { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "AddressDto") { + $extraUsings += "using Webshop.Domain.Enums;`n" + $properties = @" + public Guid Id { get; set; } + public string Street { get; set; } = string.Empty; + public string HouseNumber { get; set; } = string.Empty; + public string City { get; set; } = string.Empty; + public string PostalCode { get; set; } = string.Empty; + public string Country { get; set; } = string.Empty; + public AddressType Type { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "CategoryDto") { + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Slug { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid? ParentCategoryId { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } + public int DisplayOrder { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "CreateCategoryDto") { + $properties = @" + public string Name { get; set; } = string.Empty; + public string Slug { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid? ParentCategoryId { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } = true; + public int DisplayOrder { get; set; } = 0; +"@ + } elseif ($nameWithoutExtension -eq "CustomerDto") { + $properties = @" + public Guid Id { get; set; } + public string UserId { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string? PhoneNumber { get; set; } + public Guid? DefaultShippingAddressId { get; set; } + public Guid? DefaultBillingAddressId { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "DiscountDto") { + $extraUsings += "using Webshop.Domain.Enums;`n" + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public DiscountType Type { get; set; } + public decimal Value { get; set; } + public string? CouponCode { get; set; } + public DateTimeOffset StartDate { get; set; } + public DateTimeOffset EndDate { get; set; } + public bool IsActive { get; set; } + public int? MaxUses { get; set; } + public int CurrentUses { get; set; } + public string? Description { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "OrderSummaryDto") { + $extraUsings += "using Webshop.Domain.Enums;`n" + $properties = @" + public Guid Id { get; set; } + public string OrderNumber { get; set; } = string.Empty; + public DateTimeOffset OrderDate { get; set; } + public OrderStatus Status { get; set; } + public decimal TotalAmount { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public string PaymentMethodName { get; set; } = string.Empty; + public string ShippingMethodName { get; set; } = string.Empty; +"@ + } elseif ($nameWithoutExtension -eq "OrderDetailDto") { + $extraUsings += "using Webshop.Domain.Enums;`n" + $properties = @" + public Guid Id { get; set; } + public string OrderNumber { get; set; } = string.Empty; + public Guid CustomerId { get; set; } + public DateTimeOffset OrderDate { get; set; } + public OrderStatus Status { get; set; } + public decimal TotalAmount { get; set; } + public Guid ShippingAddressId { get; set; } + public Guid BillingAddressId { get; set; } + public Guid PaymentMethodId { get; set; } + public string? ShippingTrackingNumber { get; set; } + public DateTimeOffset? ShippedDate { get; set; } + public DateTimeOffset? DeliveredDate { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public List OrderItems { get; set; } = new List(); +"@ + } elseif ($nameWithoutExtension -eq "OrderItemDto") { + $properties = @" + public Guid Id { get; set; } + public Guid OrderId { get; set; } // Foreign Key zu Order + public Guid ProductId { get; set; } + public Guid? ProductVariantId { get; set; } + public string ProductName { get; set; } = string.Empty; + public string ProductSKU { get; set; } = string.Empty; + public int Quantity { get; set; } + public decimal UnitPrice { get; set; } + public decimal TotalPrice { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "CreateOrderDto") { + $properties = @" + public Guid? CustomerId { get; set; } // Nullable für Gastbestellung + public string? GuestEmail { get; set; } + public string? GuestPhoneNumber { get; set; } + public Guid ShippingAddressId { get; set; } + public Guid BillingAddressId { get; set; } + public Guid PaymentMethodId { get; set; } + public Guid ShippingMethodId { get; set; } + public List Items { get; set; } = new List(); +"@ + } elseif ($nameWithoutExtension -eq "CreateOrderItemDto") { + $properties = @" + public Guid ProductId { get; set; } + public Guid? ProductVariantId { get; set; } + public int Quantity { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "ReviewDto") { + $properties = @" + public Guid Id { get; set; } + public Guid ProductId { get; set; } + public Guid? CustomerId { get; set; } + public int Rating { get; set; } + public string? Title { get; set; } + public string Comment { get; set; } = string.Empty; + public DateTimeOffset ReviewDate { get; set; } + public bool IsApproved { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "CreateReviewDto") { + $properties = @" + public Guid ProductId { get; set; } + public int Rating { get; set; } + public string? Title { get; set; } + public string Comment { get; set; } = string.Empty; +"@ + } elseif ($nameWithoutExtension -eq "SettingDto") { + $properties = @" + public string Key { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public string? Description { get; set; } + public DateTimeOffset LastModifiedDate { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "PaymentMethodDto") { + $extraUsings += "using Webshop.Domain.Enums;`n" + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string? Description { get; set; } + public bool IsActive { get; set; } + public PaymentGatewayType GatewayType { get; set; } + public decimal? ProcessingFee { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "ShippingMethodDto") { + $properties = @" + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string? Description { get; set; } + public decimal Cost { get; set; } + public bool IsActive { get; set; } + public int MinDeliveryDays { get; set; } + public int MaxDeliveryDays { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "ProductVariantDto") { + $properties = @" + public Guid Id { get; set; } + public Guid ProductId { get; set; } + public string Name { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public string? SKU { get; set; } + public decimal PriceAdjustment { get; set; } + public int StockQuantity { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } +"@ + } elseif ($nameWithoutExtension -eq "SupplierDto") { + $properties = @" + public Guid Id { get; set; } = Guid.NewGuid(); + public string Name { get; set; } = string.Empty; + public string? ContactPerson { get; set; } + public string? Email { get; set; } + public string? PhoneNumber { get; set; } + public Guid? AddressId { get; set; } + public string? Notes { get; set; } +"@ + } # End DTO specific content + + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +$commonUsings +$extraUsings + +namespace $fullNamespace +{ + public class $nameWithoutExtension + { +$properties + } +} +"@ + } # Ende DTO Sektion + # Standardfall für eine Klasse, wenn keine spezielle Logik zutrifft (z.B. Domain Entities) + elseif ($Type -eq "class") { + $fileContent = @" +// Auto-generiert von CreateWebshopFiles.ps1 +$commonUsings + +namespace $fullNamespace +{ + public class $nameWithoutExtension + { + public Guid Id { get; set; } = Guid.NewGuid(); + // Fügen Sie hier weitere Eigenschaften hinzu + } +} +"@ + } + + Set-Content -Path $fullFilePath -Value $fileContent + Write-Host "Datei erstellt: $fullFilePath" -ForegroundColor Cyan +} + +# --- Dateiliste --- + +# 1. Projekt: Webshop.Domain +# Interfaces +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "ICategoryRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "ICustomerRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IDiscountRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IOrderRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IReviewRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "ISettingRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IPaymentMethodRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IShippingMethodRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "ISupplierRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" +New-CSharpFile -ProjectName "Webshop.Domain" -RelativePath "Interfaces" -FileName "IProductRepository.cs" -Type "interface" -BaseNamespace "Webshop.Domain" + + +# 2. Projekt: Webshop.Application +# DTOs +# Auth DTOs (bereits in Unterordnern, aber ich füge die Aufrufe hier für Konsistenz hinzu) +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs/Auth" -FileName "AuthResponseDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs/Auth" -FileName "LoginRequestDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs/Auth" -FileName "RegisterRequestDto.cs" -Type "class" -BaseNamespace "Webshop.Application" + +# User DTOs (bereits in Unterordnern) +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs/Users" -FileName "UserDto.cs" -Type "class" -BaseNamespace "Webshop.Application" + + +# DTOs direkt im DTOs-Ordner +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "AddressDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CategoryDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CreateCategoryDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CustomerDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "DiscountDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "OrderSummaryDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "OrderDetailDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "OrderItemDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CreateOrderDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CreateOrderItemDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "ReviewDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "CreateReviewDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "SettingDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "PaymentMethodDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "ShippingMethodDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "ProductVariantDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "SupplierDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "AdminProductDto.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "DTOs" -FileName "ProductDto.cs" -Type "class" -BaseNamespace "Webshop.Application" + + +# Services (Interfaces und Implementierungen) +# Admin/ +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "IAdminCategoryService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminCategoryService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "IAdminOrderService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminOrderService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "IAdminDiscountService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminDiscountService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "IAdminSettingService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminSettingService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminProductService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminUserService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Admin" -FileName "AdminSupplierService.cs" -Type "class" -BaseNamespace "Webshop.Application" + + +# Public/ +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Public" -FileName "ICategoryService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Public" -FileName "CategoryService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Public" -FileName "ProductService.cs" -Type "class" -BaseNamespace "Webshop.Application" + +# Customer/ +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "IOrderService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "OrderService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "ICheckoutService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "CheckoutService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "IReviewService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "ReviewService.cs" -Type "class" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "ICustomerService.cs" -Type "interface" -BaseNamespace "Webshop.Application" +New-CSharpFile -ProjectName "Webshop.Application" -RelativePath "Services/Customer" -FileName "CustomerService.cs" -Type "class" -BaseNamespace "Webshop.Application" + + +# 3. Projekt: Webshop.Infrastructure +# Repositories +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "CategoryRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "CustomerRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "DiscountRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "OrderRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "ReviewRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "SettingRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "PaymentMethodRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "ShippingMethodRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "SupplierRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" +New-CSharpFile -ProjectName "Webshop.Infrastructure" -RelativePath "Repositories" -FileName "ProductRepository.cs" -Type "class" -BaseNamespace "Webshop.Infrastructure" + +# 4. Projekt: Webshop.Api +# Controllers +# Admin/ +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminCategoriesController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminDiscountsController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminSettingsController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminOrdersController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminProductsController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminUsersController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Admin" -FileName "AdminSuppliersController.cs" -Type "class" -BaseNamespace "Webshop.Api" + + +# Public/ +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Public" -FileName "CategoriesController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Public" -FileName "ProductsController.cs" -Type "class" -BaseNamespace "Webshop.Api" + +# Customer/ +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Customer" -FileName "OrdersController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Customer" -FileName "CheckoutController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Customer" -FileName "ReviewsController.cs" -Type "class" -BaseNamespace "Webshop.Api" +New-CSharpFile -ProjectName "Webshop.Api" -RelativePath "Controllers/Customer" -FileName "ProfileController.cs" -Type "class" -BaseNamespace "Webshop.Api" + + +Write-Host "Dateierstellung abgeschlossen." -ForegroundColor Green \ No newline at end of file diff --git a/Webshop.Api/Controllers/Admin/AdminCategoriesController.cs b/Webshop.Api/Controllers/Admin/AdminCategoriesController.cs new file mode 100644 index 0000000..a9479c4 --- /dev/null +++ b/Webshop.Api/Controllers/Admin/AdminCategoriesController.cs @@ -0,0 +1,18 @@ +// 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.Admin +{ + [ApiController] + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] + public class AdminCategoriesController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Admin/AdminDiscountsController.cs b/Webshop.Api/Controllers/Admin/AdminDiscountsController.cs new file mode 100644 index 0000000..03f098a --- /dev/null +++ b/Webshop.Api/Controllers/Admin/AdminDiscountsController.cs @@ -0,0 +1,18 @@ +// 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.Admin +{ + [ApiController] + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] + public class AdminDiscountsController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Admin/AdminOrdersController.cs b/Webshop.Api/Controllers/Admin/AdminOrdersController.cs new file mode 100644 index 0000000..27d005a --- /dev/null +++ b/Webshop.Api/Controllers/Admin/AdminOrdersController.cs @@ -0,0 +1,18 @@ +// 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.Admin +{ + [ApiController] + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] + public class AdminOrdersController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Admin/AdminProductsController.cs b/Webshop.Api/Controllers/Admin/AdminProductsController.cs index 7c1bade..473350f 100644 --- a/Webshop.Api/Controllers/Admin/AdminProductsController.cs +++ b/Webshop.Api/Controllers/Admin/AdminProductsController.cs @@ -1,13 +1,18 @@ -using Microsoft.AspNetCore.Authorization; +// Auto-generiert von CreateWebshopFiles.ps1 using Microsoft.AspNetCore.Mvc; -using Webshop.Application.DTOs; // ProductDto and AdminProductDto +using Microsoft.AspNetCore.Authorization; +using Webshop.Application.DTOs; using Webshop.Application.Services.Admin; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + namespace Webshop.Api.Controllers.Admin { [ApiController] - [Route("api/v1/admin/[controller]")] // z.B. /api/v1/admin/products - [Authorize(Roles = "Admin")] // Nur Benutzer mit der Rolle "Admin" dürfen zugreifen + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] public class AdminProductsController : ControllerBase { private readonly AdminProductService _adminProductService; @@ -17,14 +22,14 @@ namespace Webshop.Api.Controllers.Admin _adminProductService = adminProductService; } - [HttpGet] // /api/v1/admin/products + [HttpGet] public async Task>> GetAdminProducts() { var products = await _adminProductService.GetAllAdminProductsAsync(); return Ok(products); } - [HttpGet("{id}")] // /api/v1/admin/products/{id} + [HttpGet("{id}")] public async Task> GetAdminProduct(Guid id) { var product = await _adminProductService.GetAdminProductByIdAsync(id); @@ -32,7 +37,7 @@ namespace Webshop.Api.Controllers.Admin return Ok(product); } - [HttpPost] // /api/v1/admin/products + [HttpPost] public async Task> CreateAdminProduct([FromBody] AdminProductDto productDto) { if (!ModelState.IsValid) return BadRequest(ModelState); @@ -40,18 +45,17 @@ namespace Webshop.Api.Controllers.Admin return CreatedAtAction(nameof(GetAdminProduct), new { id = createdProduct.Id }, createdProduct); } - [HttpPut("{id}")] // /api/v1/admin/products/{id} + [HttpPut("{id}")] public async Task UpdateAdminProduct(Guid id, [FromBody] AdminProductDto productDto) { if (id != productDto.Id) return BadRequest(); if (!ModelState.IsValid) return BadRequest(ModelState); - var success = await _adminProductService.UpdateAdminProductAsync(productDto); if (!success) return NotFound(); return NoContent(); } - [HttpDelete("{id}")] // /api/v1/admin/products/{id} + [HttpDelete("{id}")] public async Task DeleteAdminProduct(Guid id) { var success = await _adminProductService.DeleteAdminProductAsync(id); @@ -59,4 +63,4 @@ namespace Webshop.Api.Controllers.Admin return NoContent(); } } -} \ No newline at end of file +} diff --git a/Webshop.Api/Controllers/Admin/AdminSettingsController.cs b/Webshop.Api/Controllers/Admin/AdminSettingsController.cs new file mode 100644 index 0000000..12f7c1e --- /dev/null +++ b/Webshop.Api/Controllers/Admin/AdminSettingsController.cs @@ -0,0 +1,18 @@ +// 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.Admin +{ + [ApiController] + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] + public class AdminSettingsController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Admin/HomeController.cs b/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs similarity index 84% rename from Webshop.Api/Controllers/Admin/HomeController.cs rename to Webshop.Api/Controllers/Admin/AdminSuppliersController.cs index d080c2c..d588e26 100644 --- a/Webshop.Api/Controllers/Admin/HomeController.cs +++ b/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs @@ -1,8 +1,10 @@ -// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs +// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Webshop.Application.DTOs; // SupplierDto -using Webshop.Application.Services.Admin; +using Webshop.Application.Services.Admin; // AdminSupplierService +using System.Collections.Generic; // Für IEnumerable +using System.Threading.Tasks; // Für Task namespace Webshop.Api.Controllers.Admin { @@ -11,6 +13,7 @@ namespace Webshop.Api.Controllers.Admin [Authorize(Roles = "Admin")] // Nur Admins public class AdminSuppliersController : ControllerBase { + // HIER MUSS NUR EINE EINZIGE DEKLARATION STEHEN private readonly AdminSupplierService _adminSupplierService; public AdminSuppliersController(AdminSupplierService adminSupplierService) diff --git a/Webshop.Api/Controllers/Admin/AdminUsersController.cs b/Webshop.Api/Controllers/Admin/AdminUsersController.cs index 25d1e4c..5c708fd 100644 --- a/Webshop.Api/Controllers/Admin/AdminUsersController.cs +++ b/Webshop.Api/Controllers/Admin/AdminUsersController.cs @@ -1,13 +1,18 @@ -using Microsoft.AspNetCore.Authorization; +// Auto-generiert von CreateWebshopFiles.ps1 using Microsoft.AspNetCore.Mvc; -using Webshop.Application.DTOs.Users; // UserDto +using Microsoft.AspNetCore.Authorization; +using Webshop.Application.DTOs.Users; using Webshop.Application.Services.Admin; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + namespace Webshop.Api.Controllers.Admin { [ApiController] - [Route("api/v1/admin/[controller]")] // z.B. /api/v1/admin/users - [Authorize(Roles = "Admin")] // Nur Benutzer mit der Rolle "Admin" dürfen zugreifen + [Route("api/v1/admin/[controller]")] + [Authorize(Roles = "Admin")] public class AdminUsersController : ControllerBase { private readonly AdminUserService _adminUserService; @@ -17,20 +22,19 @@ namespace Webshop.Api.Controllers.Admin _adminUserService = adminUserService; } - [HttpGet] // /api/v1/admin/users + [HttpGet] public async Task>> GetAllUsers() { var users = await _adminUserService.GetAllUsersAsync(); return Ok(users); } - [HttpGet("{userId}")] // /api/v1/admin/users/{userId} + [HttpGet("{userId}")] public async Task> GetUserById(string userId) { var user = await _adminUserService.GetUserByIdAsync(userId); if (user == null) return NotFound(); return Ok(user); } - // TODO: Hier könnten weitere Methoden für User-Verwaltung (Rollen ändern, löschen etc.) hinzukommen } -} \ No newline at end of file +} diff --git a/Webshop.Api/Controllers/Customer/CheckoutController.cs b/Webshop.Api/Controllers/Customer/CheckoutController.cs new file mode 100644 index 0000000..80fa208 --- /dev/null +++ b/Webshop.Api/Controllers/Customer/CheckoutController.cs @@ -0,0 +1,18 @@ +// 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 CheckoutController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Customer/OrdersController.cs b/Webshop.Api/Controllers/Customer/OrdersController.cs index 67456a8..346e435 100644 --- a/Webshop.Api/Controllers/Customer/OrdersController.cs +++ b/Webshop.Api/Controllers/Customer/OrdersController.cs @@ -1,23 +1,22 @@ -using Microsoft.AspNetCore.Authorization; +// Auto-generiert von CreateWebshopFiles.ps1 using Microsoft.AspNetCore.Mvc; -// using Webshop.Application.DTOs.Orders; // Später erstellen -// using Webshop.Application.Services.Customer; // Später erstellen +using Microsoft.AspNetCore.Authorization; -namespace Webshop.Api.Controllers.Customer // Beachten Sie den Namespace +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Api.Controllers.Customer { [ApiController] - [Route("api/v1/customer/[controller]")] // z.B. /api/v1/customer/orders - [Authorize(Roles = "Customer")] // Nur Benutzer mit der Rolle "Customer" dürfen zugreifen + [Route("api/v1/customer/[controller]")] + [Authorize(Roles = "Customer")] public class OrdersController : ControllerBase { - // Beispiel-Endpunkt für eingeloggte Kunden [HttpGet("my-orders")] public async Task GetMyOrders() { - // Hier würden Sie die Bestellungen des eingeloggten Benutzers abrufen. - // Die Benutzer-ID können Sie über User.FindFirstValue(ClaimTypes.NameIdentifier) abrufen. - // return Ok(await _orderService.GetOrdersForCurrentUserAsync(User.FindFirstValue(ClaimTypes.NameIdentifier))); - return Ok(new { Message = "Dies sind Ihre Bestellungen (Platzhalter)." }); + return Ok(new { Message = "Dies ist Ihr persönlicher Bestellverlauf (Platzhalter)." }); } } -} \ No newline at end of file +} diff --git a/Webshop.Api/Controllers/Customer/ProfileController.cs b/Webshop.Api/Controllers/Customer/ProfileController.cs new file mode 100644 index 0000000..f37bf38 --- /dev/null +++ b/Webshop.Api/Controllers/Customer/ProfileController.cs @@ -0,0 +1,18 @@ +// 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 + { + + } +} diff --git a/Webshop.Api/Controllers/Customer/ReviewsController.cs b/Webshop.Api/Controllers/Customer/ReviewsController.cs new file mode 100644 index 0000000..36be3d0 --- /dev/null +++ b/Webshop.Api/Controllers/Customer/ReviewsController.cs @@ -0,0 +1,18 @@ +// 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 ReviewsController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Public/CategoriesController.cs b/Webshop.Api/Controllers/Public/CategoriesController.cs new file mode 100644 index 0000000..5cf9af6 --- /dev/null +++ b/Webshop.Api/Controllers/Public/CategoriesController.cs @@ -0,0 +1,18 @@ +// 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.Public +{ + [ApiController] + [Route("api/v1/public/[controller]")] + [AllowAnonymous] + public class CategoriesController : ControllerBase + { + + } +} diff --git a/Webshop.Api/Controllers/Public/ProductsController.cs b/Webshop.Api/Controllers/Public/ProductsController.cs index 9c1d08f..eabe6e1 100644 --- a/Webshop.Api/Controllers/Public/ProductsController.cs +++ b/Webshop.Api/Controllers/Public/ProductsController.cs @@ -1,29 +1,32 @@ -using Microsoft.AspNetCore.Mvc; -using Webshop.Application.DTOs; // ProductDto -using Webshop.Application.Services.Public; // ProductCatalogService +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; +using Webshop.Application.DTOs; +using Webshop.Application.Services.Public; -namespace Webshop.Api.Controllers.Public // Beachten Sie den Namespace +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Api.Controllers.Public { [ApiController] - [Route("api/v1/public/[controller]")] // z.B. /api/v1/public/products - [AllowAnonymous] // Jeder darf hier zugreifen (Gast oder eingeloggter User) + [Route("api/v1/public/[controller]")] + [AllowAnonymous] public class ProductsController : ControllerBase { - private readonly ProductService _productCatalogService; // Umbenannt + private readonly ProductService _productService; // ServiceName nach Ihrer Konvention beibehalten - public ProductsController(ProductService productCatalogService) // Injiziert den umbenannten Service + public ProductsController(ProductService productService) { - _productCatalogService = productCatalogService; + _productService = productService; } - [HttpGet] // /api/v1/public/products + [HttpGet] public async Task>> GetAllProducts() { - var products = await _productCatalogService.GetAllProductsAsync(); // Ruft Service-Methode auf + var products = await _productService.GetAllProductsAsync(); return Ok(products); } - // Keine POST, PUT, DELETE hier für öffentliche Zugriffe. - // Diese gehören in den AdminProductsController. } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/AddressDto.cs b/Webshop.Application/DTOs/AddressDto.cs new file mode 100644 index 0000000..5c9a03a --- /dev/null +++ b/Webshop.Application/DTOs/AddressDto.cs @@ -0,0 +1,20 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + + +namespace Webshop.Application.DTOs +{ + public class AddressDto + { + public Guid Id { get; set; } + public string Street { get; set; } = string.Empty; + public string HouseNumber { get; set; } = string.Empty; + public string City { get; set; } = string.Empty; + public string PostalCode { get; set; } = string.Empty; + public string Country { get; set; } = string.Empty; + public AddressType Type { get; set; } + } +} diff --git a/Webshop.Application/DTOs/AdminProductDto.cs b/Webshop.Application/DTOs/AdminProductDto.cs index 8d827aa..01aaf27 100644 --- a/Webshop.Application/DTOs/AdminProductDto.cs +++ b/Webshop.Application/DTOs/AdminProductDto.cs @@ -1,4 +1,10 @@ -namespace Webshop.Application.DTOs +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs { public class AdminProductDto { @@ -14,9 +20,9 @@ public decimal? Weight { get; set; } public string? ImageUrl { get; set; } public string Slug { get; set; } = string.Empty; - public DateTimeOffset CreatedDate { get; set; } + public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.UtcNow; public DateTimeOffset? LastModifiedDate { get; set; } public Guid? SupplierId { get; set; } - public decimal? PurchasePrice { get; set; } // Admin-spezifisches Feld + public decimal? PurchasePrice { get; set; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/Auth/AuthResponseDto.cs b/Webshop.Application/DTOs/Auth/AuthResponseDto.cs index 715a33a..6a8d5ae 100644 --- a/Webshop.Application/DTOs/Auth/AuthResponseDto.cs +++ b/Webshop.Application/DTOs/Auth/AuthResponseDto.cs @@ -1,4 +1,10 @@ -namespace Webshop.Application.DTOs.Auth +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs.Auth { public class AuthResponseDto { @@ -9,4 +15,4 @@ public string Email { get; set; } = string.Empty; public List Roles { get; set; } = new List(); } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/Auth/LoginRequestDto.cs b/Webshop.Application/DTOs/Auth/LoginRequestDto.cs index 12ea00a..beaf561 100644 --- a/Webshop.Application/DTOs/Auth/LoginRequestDto.cs +++ b/Webshop.Application/DTOs/Auth/LoginRequestDto.cs @@ -1,4 +1,9 @@ -using System.ComponentModel.DataAnnotations; +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; + namespace Webshop.Application.DTOs.Auth { @@ -11,4 +16,4 @@ namespace Webshop.Application.DTOs.Auth [Required(ErrorMessage = "Passwort ist erforderlich.")] public string Password { get; set; } = string.Empty; } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/Auth/RegisterRequestDto.cs b/Webshop.Application/DTOs/Auth/RegisterRequestDto.cs index bbd754f..15ecf78 100644 --- a/Webshop.Application/DTOs/Auth/RegisterRequestDto.cs +++ b/Webshop.Application/DTOs/Auth/RegisterRequestDto.cs @@ -1,4 +1,9 @@ -using System.ComponentModel.DataAnnotations; +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; + namespace Webshop.Application.DTOs.Auth { @@ -19,4 +24,4 @@ namespace Webshop.Application.DTOs.Auth public string? FirstName { get; set; } public string? LastName { get; set; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/CategoryDto.cs b/Webshop.Application/DTOs/CategoryDto.cs new file mode 100644 index 0000000..08c49e6 --- /dev/null +++ b/Webshop.Application/DTOs/CategoryDto.cs @@ -0,0 +1,20 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CategoryDto + { + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Slug { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid? ParentCategoryId { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } + public int DisplayOrder { get; set; } + } +} diff --git a/Webshop.Application/DTOs/CreateCategoryDto.cs b/Webshop.Application/DTOs/CreateCategoryDto.cs new file mode 100644 index 0000000..a5ac9fe --- /dev/null +++ b/Webshop.Application/DTOs/CreateCategoryDto.cs @@ -0,0 +1,19 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CreateCategoryDto + { + public string Name { get; set; } = string.Empty; + public string Slug { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid? ParentCategoryId { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } = true; + public int DisplayOrder { get; set; } = 0; + } +} diff --git a/Webshop.Application/DTOs/CreateOrderDto.cs b/Webshop.Application/DTOs/CreateOrderDto.cs new file mode 100644 index 0000000..e048f97 --- /dev/null +++ b/Webshop.Application/DTOs/CreateOrderDto.cs @@ -0,0 +1,20 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CreateOrderDto + { + public Guid? CustomerId { get; set; } // Nullable für Gastbestellung + public string? GuestEmail { get; set; } + public string? GuestPhoneNumber { get; set; } + public Guid ShippingAddressId { get; set; } + public Guid BillingAddressId { get; set; } + public Guid PaymentMethodId { get; set; } + public Guid ShippingMethodId { get; set; } + public List Items { get; set; } = new List(); + } +} diff --git a/Webshop.Application/DTOs/CreateOrderItemDto.cs b/Webshop.Application/DTOs/CreateOrderItemDto.cs new file mode 100644 index 0000000..447e109 --- /dev/null +++ b/Webshop.Application/DTOs/CreateOrderItemDto.cs @@ -0,0 +1,15 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CreateOrderItemDto + { + public Guid ProductId { get; set; } + public Guid? ProductVariantId { get; set; } + public int Quantity { get; set; } + } +} diff --git a/Webshop.Application/DTOs/CreateReviewDto.cs b/Webshop.Application/DTOs/CreateReviewDto.cs new file mode 100644 index 0000000..b4081fd --- /dev/null +++ b/Webshop.Application/DTOs/CreateReviewDto.cs @@ -0,0 +1,16 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CreateReviewDto + { + public Guid ProductId { get; set; } + public int Rating { get; set; } + public string? Title { get; set; } + public string Comment { get; set; } = string.Empty; + } +} diff --git a/Webshop.Application/DTOs/CustomerDto.cs b/Webshop.Application/DTOs/CustomerDto.cs new file mode 100644 index 0000000..65b72db --- /dev/null +++ b/Webshop.Application/DTOs/CustomerDto.cs @@ -0,0 +1,20 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class CustomerDto + { + public Guid Id { get; set; } + public string UserId { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string? PhoneNumber { get; set; } + public Guid? DefaultShippingAddressId { get; set; } + public Guid? DefaultBillingAddressId { get; set; } + } +} diff --git a/Webshop.Application/DTOs/DiscountDto.cs b/Webshop.Application/DTOs/DiscountDto.cs new file mode 100644 index 0000000..83867c7 --- /dev/null +++ b/Webshop.Application/DTOs/DiscountDto.cs @@ -0,0 +1,24 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + + +namespace Webshop.Application.DTOs +{ + public class DiscountDto + { + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public DiscountType Type { get; set; } + public decimal Value { get; set; } + public string? CouponCode { get; set; } + public DateTimeOffset StartDate { get; set; } + public DateTimeOffset EndDate { get; set; } + public bool IsActive { get; set; } + public int? MaxUses { get; set; } + public int CurrentUses { get; set; } + public string? Description { get; set; } + } +} diff --git a/Webshop.Application/DTOs/OrderDetailDto.cs b/Webshop.Application/DTOs/OrderDetailDto.cs new file mode 100644 index 0000000..bce361b --- /dev/null +++ b/Webshop.Application/DTOs/OrderDetailDto.cs @@ -0,0 +1,27 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + + +namespace Webshop.Application.DTOs +{ + public class OrderDetailDto + { + public Guid Id { get; set; } + public string OrderNumber { get; set; } = string.Empty; + public Guid CustomerId { get; set; } + public DateTimeOffset OrderDate { get; set; } + public OrderStatus Status { get; set; } + public decimal TotalAmount { get; set; } + public Guid ShippingAddressId { get; set; } + public Guid BillingAddressId { get; set; } + public Guid PaymentMethodId { get; set; } + public string? ShippingTrackingNumber { get; set; } + public DateTimeOffset? ShippedDate { get; set; } + public DateTimeOffset? DeliveredDate { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public List OrderItems { get; set; } = new List(); + } +} diff --git a/Webshop.Application/DTOs/OrderItemDto.cs b/Webshop.Application/DTOs/OrderItemDto.cs new file mode 100644 index 0000000..7db8b58 --- /dev/null +++ b/Webshop.Application/DTOs/OrderItemDto.cs @@ -0,0 +1,21 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class OrderItemDto + { + public Guid Id { get; set; } + public Guid OrderId { get; set; } // Foreign Key zu Order + public Guid ProductId { get; set; } + public Guid? ProductVariantId { get; set; } + public string ProductName { get; set; } = string.Empty; + public string ProductSKU { get; set; } = string.Empty; + public int Quantity { get; set; } + public decimal UnitPrice { get; set; } + public decimal TotalPrice { get; set; } + } +} diff --git a/Webshop.Application/DTOs/OrderSummaryDto.cs b/Webshop.Application/DTOs/OrderSummaryDto.cs new file mode 100644 index 0000000..9df0d5a --- /dev/null +++ b/Webshop.Application/DTOs/OrderSummaryDto.cs @@ -0,0 +1,21 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + + +namespace Webshop.Application.DTOs +{ + public class OrderSummaryDto + { + public Guid Id { get; set; } + public string OrderNumber { get; set; } = string.Empty; + public DateTimeOffset OrderDate { get; set; } + public OrderStatus Status { get; set; } + public decimal TotalAmount { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public string PaymentMethodName { get; set; } = string.Empty; + public string ShippingMethodName { get; set; } = string.Empty; + } +} diff --git a/Webshop.Application/DTOs/PaymentMethodDto.cs b/Webshop.Application/DTOs/PaymentMethodDto.cs new file mode 100644 index 0000000..b82c879 --- /dev/null +++ b/Webshop.Application/DTOs/PaymentMethodDto.cs @@ -0,0 +1,19 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + + +namespace Webshop.Application.DTOs +{ + public class PaymentMethodDto + { + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string? Description { get; set; } + public bool IsActive { get; set; } + public PaymentGatewayType GatewayType { get; set; } + public decimal? ProcessingFee { get; set; } + } +} diff --git a/Webshop.Application/DTOs/ProductDto.cs b/Webshop.Application/DTOs/ProductDto.cs index a223feb..08b2e2b 100644 --- a/Webshop.Application/DTOs/ProductDto.cs +++ b/Webshop.Application/DTOs/ProductDto.cs @@ -1,15 +1,21 @@ -namespace Webshop.Application.DTOs +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs { public class ProductDto { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; - public string SKU { get; set; } = string.Empty; // STELLEN SIE SICHER, DASS DIES DA IST + public string SKU { get; set; } = string.Empty; public decimal Price { get; set; } public bool IsActive { get; set; } public bool IsInStock { get; set; } public int StockQuantity { get; set; } - public string? ImageUrl { get; set; } // STELLEN SIE SICHER, DASS DIES DA IST + public string? ImageUrl { get; set; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/ProductVariantDto.cs b/Webshop.Application/DTOs/ProductVariantDto.cs new file mode 100644 index 0000000..b73f79f --- /dev/null +++ b/Webshop.Application/DTOs/ProductVariantDto.cs @@ -0,0 +1,21 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class ProductVariantDto + { + public Guid Id { get; set; } + public Guid ProductId { get; set; } + public string Name { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public string? SKU { get; set; } + public decimal PriceAdjustment { get; set; } + public int StockQuantity { get; set; } + public string? ImageUrl { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/Webshop.Application/DTOs/ReviewDto.cs b/Webshop.Application/DTOs/ReviewDto.cs new file mode 100644 index 0000000..ad36b04 --- /dev/null +++ b/Webshop.Application/DTOs/ReviewDto.cs @@ -0,0 +1,20 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class ReviewDto + { + public Guid Id { get; set; } + public Guid ProductId { get; set; } + public Guid? CustomerId { get; set; } + public int Rating { get; set; } + public string? Title { get; set; } + public string Comment { get; set; } = string.Empty; + public DateTimeOffset ReviewDate { get; set; } + public bool IsApproved { get; set; } + } +} diff --git a/Webshop.Application/DTOs/SettingDto.cs b/Webshop.Application/DTOs/SettingDto.cs new file mode 100644 index 0000000..b2eeb41 --- /dev/null +++ b/Webshop.Application/DTOs/SettingDto.cs @@ -0,0 +1,16 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class SettingDto + { + public string Key { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public string? Description { get; set; } + public DateTimeOffset LastModifiedDate { get; set; } + } +} diff --git a/Webshop.Application/DTOs/ShippingMethodDto.cs b/Webshop.Application/DTOs/ShippingMethodDto.cs new file mode 100644 index 0000000..1d6f3a9 --- /dev/null +++ b/Webshop.Application/DTOs/ShippingMethodDto.cs @@ -0,0 +1,19 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs +{ + public class ShippingMethodDto + { + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string? Description { get; set; } + public decimal Cost { get; set; } + public bool IsActive { get; set; } + public int MinDeliveryDays { get; set; } + public int MaxDeliveryDays { get; set; } + } +} diff --git a/Webshop.Application/DTOs/SupplierDto.cs b/Webshop.Application/DTOs/SupplierDto.cs index eab65c0..ccc4c9e 100644 --- a/Webshop.Application/DTOs/SupplierDto.cs +++ b/Webshop.Application/DTOs/SupplierDto.cs @@ -1,14 +1,19 @@ -// src/Webshop.Application/DTOs/SupplierDto.cs +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + namespace Webshop.Application.DTOs { public class SupplierDto { - public Guid Id { get; set; } = Guid.NewGuid(); // Für PUT/GET, bei POST optional + public Guid Id { get; set; } = Guid.NewGuid(); public string Name { get; set; } = string.Empty; public string? ContactPerson { get; set; } public string? Email { get; set; } public string? PhoneNumber { get; set; } - public Guid? AddressId { get; set; } // Wenn Sie Adressen haben, sonst null + public Guid? AddressId { get; set; } public string? Notes { get; set; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/DTOs/Users/UserDto.cs b/Webshop.Application/DTOs/Users/UserDto.cs index c2590da..cd031f5 100644 --- a/Webshop.Application/DTOs/Users/UserDto.cs +++ b/Webshop.Application/DTOs/Users/UserDto.cs @@ -1,4 +1,10 @@ -namespace Webshop.Application.DTOs.Users +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.DTOs.Users { public class UserDto { @@ -6,7 +12,7 @@ public string Email { get; set; } = string.Empty; public string UserName { get; set; } = string.Empty; public List Roles { get; set; } = new List(); - public DateTimeOffset CreatedDate { get; set; } // Placeholder, as IdentityUser doesn't have it directly + public DateTimeOffset CreatedDate { get; set; } public bool EmailConfirmed { get; set; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/Services/Admin/AdminCategoryService.cs b/Webshop.Application/Services/Admin/AdminCategoryService.cs new file mode 100644 index 0000000..df964eb --- /dev/null +++ b/Webshop.Application/Services/Admin/AdminCategoryService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Admin +{ + public class AdminCategoryService : IAdminCategoryService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public AdminCategoryService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Admin/AdminDiscountService.cs b/Webshop.Application/Services/Admin/AdminDiscountService.cs new file mode 100644 index 0000000..f74f951 --- /dev/null +++ b/Webshop.Application/Services/Admin/AdminDiscountService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Admin +{ + public class AdminDiscountService : IAdminDiscountService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public AdminDiscountService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Admin/AdminOrderService.cs b/Webshop.Application/Services/Admin/AdminOrderService.cs new file mode 100644 index 0000000..c31b721 --- /dev/null +++ b/Webshop.Application/Services/Admin/AdminOrderService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Admin +{ + public class AdminOrderService : IAdminOrderService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public AdminOrderService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Admin/AdminProductService.cs b/Webshop.Application/Services/Admin/AdminProductService.cs index b273d05..021d550 100644 --- a/Webshop.Application/Services/Admin/AdminProductService.cs +++ b/Webshop.Application/Services/Admin/AdminProductService.cs @@ -1,12 +1,15 @@ -// src/Webshop.Application/Services/Admin/AdminProductService.cs -using Webshop.Application.DTOs; // AdminProductDto +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; -using System.Collections.Generic; // Sicherstellen, dass für IEnumerable vorhanden + namespace Webshop.Application.Services.Admin { - public class AdminProductService + public class AdminProductService : IAdminProductService { private readonly IProductRepository _productRepository; @@ -15,111 +18,10 @@ namespace Webshop.Application.Services.Admin _productRepository = productRepository; } - public async Task> GetAllAdminProductsAsync() - { - var products = await _productRepository.GetAllProductsAsync(); - return products.Select(p => new AdminProductDto - { - Id = p.Id, - Name = p.Name, - Description = p.Description, - SKU = p.SKU, - Price = p.Price, - OldPrice = p.OldPrice, - IsActive = p.IsActive, - IsInStock = p.IsInStock, - StockQuantity = p.StockQuantity, - Weight = p.Weight, - ImageUrl = p.ImageUrl, - Slug = p.Slug, - CreatedDate = p.CreatedDate, - LastModifiedDate = p.LastModifiedDate, - SupplierId = p.SupplierId, - PurchasePrice = p.PurchasePrice - }).ToList(); - } - - public async Task GetAdminProductByIdAsync(Guid id) - { - var product = await _productRepository.GetProductByIdAsync(id); - if (product == null) return null; - - return new AdminProductDto - { - Id = product.Id, - Name = product.Name, - Description = product.Description, - SKU = product.SKU, - Price = product.Price, - OldPrice = product.OldPrice, - IsActive = product.IsActive, - IsInStock = product.IsInStock, - StockQuantity = product.StockQuantity, - Weight = product.Weight, - ImageUrl = product.ImageUrl, - Slug = product.Slug, - CreatedDate = product.CreatedDate, - LastModifiedDate = product.LastModifiedDate, - SupplierId = product.SupplierId, - PurchasePrice = product.PurchasePrice - }; - } - - public async Task CreateAdminProductAsync(AdminProductDto productDto) - { - var newProduct = new Product - { - Id = Guid.NewGuid(), - Name = productDto.Name, - Description = productDto.Description, - SKU = productDto.SKU, - Price = productDto.Price, - OldPrice = productDto.OldPrice, - IsActive = productDto.IsActive, - IsInStock = productDto.IsInStock, - StockQuantity = productDto.StockQuantity, - Weight = productDto.Weight, - ImageUrl = productDto.ImageUrl, - Slug = productDto.Slug, - CreatedDate = DateTimeOffset.UtcNow, - SupplierId = productDto.SupplierId, - PurchasePrice = productDto.PurchasePrice - }; - await _productRepository.AddProductAsync(newProduct); - productDto.Id = newProduct.Id; - return productDto; - } - - public async Task UpdateAdminProductAsync(AdminProductDto productDto) - { - var existingProduct = await _productRepository.GetProductByIdAsync(productDto.Id); - if (existingProduct == null) return false; - - existingProduct.Name = productDto.Name; - existingProduct.Description = productDto.Description; - existingProduct.SKU = productDto.SKU; - existingProduct.Price = productDto.Price; - existingProduct.OldPrice = productDto.OldPrice; - existingProduct.IsActive = productDto.IsActive; - existingProduct.IsInStock = productDto.IsInStock; - existingProduct.StockQuantity = productDto.StockQuantity; - existingProduct.Weight = productDto.Weight; - existingProduct.ImageUrl = productDto.ImageUrl; - existingProduct.Slug = productDto.Slug; - existingProduct.LastModifiedDate = DateTimeOffset.UtcNow; - existingProduct.SupplierId = productDto.SupplierId; - existingProduct.PurchasePrice = productDto.PurchasePrice; - - await _productRepository.UpdateProductAsync(existingProduct); - return true; - } - - public async Task DeleteAdminProductAsync(Guid id) - { - var product = await _productRepository.GetProductByIdAsync(id); - if (product == null) return false; - await _productRepository.DeleteProductAsync(product.Id); // Verwende product.Id - return true; - } + public async Task> GetAllAdminProductsAsync() { return new List(); } + public async Task GetAdminProductByIdAsync(Guid id) { return null; } + public async Task CreateAdminProductAsync(AdminProductDto productDto) { return null; } + public async Task UpdateAdminProductAsync(AdminProductDto productDto) { return false; } + public async Task DeleteAdminProductAsync(Guid id) { return false; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/Services/Admin/AdminSettingService.cs b/Webshop.Application/Services/Admin/AdminSettingService.cs new file mode 100644 index 0000000..a84bbcd --- /dev/null +++ b/Webshop.Application/Services/Admin/AdminSettingService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Admin +{ + public class AdminSettingService : IAdminSettingService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public AdminSettingService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Admin/AdminSupplierService.cs b/Webshop.Application/Services/Admin/AdminSupplierService.cs index 5c9755c..56f25c0 100644 --- a/Webshop.Application/Services/Admin/AdminSupplierService.cs +++ b/Webshop.Application/Services/Admin/AdminSupplierService.cs @@ -1,12 +1,15 @@ -// src/Webshop.Application/Services/Admin/AdminSupplierService.cs -using Webshop.Application.DTOs; // SupplierDto +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; -using System.Collections.Generic; // Für IEnumerable + namespace Webshop.Application.Services.Admin { - public class AdminSupplierService + public class AdminSupplierService : IAdminSupplierService { private readonly ISupplierRepository _supplierRepository; @@ -15,54 +18,10 @@ namespace Webshop.Application.Services.Admin _supplierRepository = supplierRepository; } - public async Task> GetAllSuppliersAsync() - { - var suppliers = await _supplierRepository.GetAllSuppliersAsync(); - return suppliers.Select(s => new SupplierDto - { - Id = s.Id, - Name = s.Name, - ContactPerson = s.ContactPerson, - Email = s.Email, - PhoneNumber = s.PhoneNumber, - AddressId = s.AddressId, - Notes = s.Notes - }).ToList(); - } - - public async Task GetSupplierByIdAsync(Guid id) - { - var supplier = await _supplierRepository.GetSupplierByIdAsync(id); - if (supplier == null) return null; - return new SupplierDto - { - Id = supplier.Id, - Name = supplier.Name, - ContactPerson = supplier.ContactPerson, - Email = supplier.Email, - PhoneNumber = supplier.PhoneNumber, - AddressId = supplier.AddressId, - Notes = supplier.Notes - }; - } - - public async Task CreateSupplierAsync(SupplierDto supplierDto) - { - var newSupplier = new Supplier - { - Id = Guid.NewGuid(), // API generiert die ID - Name = supplierDto.Name, - ContactPerson = supplierDto.ContactPerson, - Email = supplierDto.Email, - PhoneNumber = supplierDto.PhoneNumber, - AddressId = supplierDto.AddressId, - Notes = supplierDto.Notes - }; - await _supplierRepository.AddSupplierAsync(newSupplier); - supplierDto.Id = newSupplier.Id; // ID zurückschreiben - return supplierDto; - } - - // TODO: UpdateSupplierAsync, DeleteSupplierAsync + // HIER KOMMT DER VORHERIGE ADMINSUPPLIERSERVICE CODE HIN (GetAllSuppliersAsync, CreateSupplierAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllSuppliersAsync() { return new List(); } + public async Task GetSupplierByIdAsync(Guid id) { return null; } + public async Task CreateSupplierAsync(SupplierDto supplierDto) { return null; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/Services/Admin/AdminUserService.cs b/Webshop.Application/Services/Admin/AdminUserService.cs index fc38e71..a54416b 100644 --- a/Webshop.Application/Services/Admin/AdminUserService.cs +++ b/Webshop.Application/Services/Admin/AdminUserService.cs @@ -1,12 +1,15 @@ -// src/Webshop.Application/Services/Admin/AdminUserService.cs +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs.Users; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; -using Webshop.Application.DTOs.Users; // UserDto -using System.Collections.Generic; // Sicherstellen, dass für IEnumerable vorhanden + namespace Webshop.Application.Services.Admin { - public class AdminUserService + public class AdminUserService : IAdminUserService { private readonly UserManager _userManager; @@ -15,47 +18,9 @@ namespace Webshop.Application.Services.Admin _userManager = userManager; } - public async Task> GetAllUsersAsync() - { - var users = await _userManager.Users.ToListAsync(); - - var userDtos = new List(); - foreach (var user in users) - { - var roles = await _userManager.GetRolesAsync(user); - userDtos.Add(new UserDto - { - Id = user.Id, - Email = user.Email ?? string.Empty, - UserName = user.UserName ?? string.Empty, - Roles = roles.ToList(), - // LockoutEnd kann als Näherung für CreatedDate verwendet werden, - // da IdentityUser keine direkte CreatedDate-Eigenschaft hat. - // Ideal wäre es, ein CustomUser-Modell zu verwenden, das von IdentityUser erbt. - CreatedDate = user.LockoutEnd ?? DateTimeOffset.MinValue, - EmailConfirmed = user.EmailConfirmed - }); - } - return userDtos; - } - - public async Task GetUserByIdAsync(string userId) - { - var user = await _userManager.FindByIdAsync(userId); - if (user == null) return null; - - var roles = await _userManager.GetRolesAsync(user); - return new UserDto - { - Id = user.Id, - Email = user.Email ?? string.Empty, - UserName = user.UserName ?? string.Empty, - Roles = roles.ToList(), - CreatedDate = user.LockoutEnd ?? DateTimeOffset.MinValue, - EmailConfirmed = user.EmailConfirmed - }; - } - - // TODO: Methoden zum Aktualisieren von Rollen, Löschen von Benutzern etc. + // HIER KOMMT DER VORHERIGE ADMINUSERSERVICE CODE HIN (GetAllUsersAsync, GetUserByIdAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllUsersAsync() { return new List(); } + public async Task GetUserByIdAsync(string userId) { return null; } } -} \ No newline at end of file +} diff --git a/Webshop.Application/Services/Admin/IAdminCategoryService.cs b/Webshop.Application/Services/Admin/IAdminCategoryService.cs new file mode 100644 index 0000000..51deaaf --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminCategoryService.cs @@ -0,0 +1,16 @@ +// 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.Admin +{ + public interface IAdminCategoryService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Admin/IAdminDiscountService.cs b/Webshop.Application/Services/Admin/IAdminDiscountService.cs new file mode 100644 index 0000000..f581e01 --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminDiscountService.cs @@ -0,0 +1,16 @@ +// 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.Admin +{ + public interface IAdminDiscountService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Admin/IAdminOrderService.cs b/Webshop.Application/Services/Admin/IAdminOrderService.cs new file mode 100644 index 0000000..26256c6 --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminOrderService.cs @@ -0,0 +1,16 @@ +// 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.Admin +{ + public interface IAdminOrderService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Admin/IAdminProductService.cs b/Webshop.Application/Services/Admin/IAdminProductService.cs new file mode 100644 index 0000000..fbe3817 --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminProductService.cs @@ -0,0 +1,16 @@ +// src/Webshop.Application/Services/Admin/IAdminProductService.cs +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; // AdminProductDto + +namespace Webshop.Application.Services.Admin +{ + public interface IAdminProductService + { + Task> GetAllAdminProductsAsync(); + Task GetAdminProductByIdAsync(Guid id); + Task CreateAdminProductAsync(AdminProductDto productDto); + Task UpdateAdminProductAsync(AdminProductDto productDto); + Task DeleteAdminProductAsync(Guid id); + } +} \ No newline at end of file diff --git a/Webshop.Application/Services/Admin/IAdminSettingService.cs b/Webshop.Application/Services/Admin/IAdminSettingService.cs new file mode 100644 index 0000000..92da1b5 --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminSettingService.cs @@ -0,0 +1,16 @@ +// 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.Admin +{ + public interface IAdminSettingService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Admin/IAdminSupplierService.cs b/Webshop.Application/Services/Admin/IAdminSupplierService.cs new file mode 100644 index 0000000..e2943db --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminSupplierService.cs @@ -0,0 +1,16 @@ +// src/Webshop.Application/Services/Admin/IAdminSupplierService.cs +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; // SupplierDto + +namespace Webshop.Application.Services.Admin +{ + public interface IAdminSupplierService + { + Task> GetAllSuppliersAsync(); + Task GetSupplierByIdAsync(Guid id); + Task CreateSupplierAsync(SupplierDto supplierDto); + // Task UpdateSupplierAsync(SupplierDto supplierDto); // Beispiel für zukünftige Methode + // Task DeleteSupplierAsync(Guid id); // Beispiel für zukünftige Methode + } +} \ No newline at end of file diff --git a/Webshop.Application/Services/Admin/IAdminUserService.cs b/Webshop.Application/Services/Admin/IAdminUserService.cs new file mode 100644 index 0000000..a81d1d0 --- /dev/null +++ b/Webshop.Application/Services/Admin/IAdminUserService.cs @@ -0,0 +1,15 @@ +// 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> GetAllUsersAsync(); + Task GetUserByIdAsync(string userId); + // Task UpdateUserRolesAsync(string userId, List newRoles); // Beispiel für zukünftige Methode + // Task DeleteUserAsync(string userId); // Beispiel für zukünftige Methode + } +} \ No newline at end of file diff --git a/Webshop.Application/Services/Customer/CheckoutService.cs b/Webshop.Application/Services/Customer/CheckoutService.cs new file mode 100644 index 0000000..9eeb88f --- /dev/null +++ b/Webshop.Application/Services/Customer/CheckoutService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Customer +{ + public class CheckoutService : ICheckoutService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public CheckoutService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Customer/CustomerService.cs b/Webshop.Application/Services/Customer/CustomerService.cs new file mode 100644 index 0000000..314b69e --- /dev/null +++ b/Webshop.Application/Services/Customer/CustomerService.cs @@ -0,0 +1,17 @@ +// 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 + } +} diff --git a/Webshop.Application/Services/Customer/ICheckoutService.cs b/Webshop.Application/Services/Customer/ICheckoutService.cs new file mode 100644 index 0000000..e1dc023 --- /dev/null +++ b/Webshop.Application/Services/Customer/ICheckoutService.cs @@ -0,0 +1,16 @@ +// 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 ICheckoutService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Customer/ICustomerService.cs b/Webshop.Application/Services/Customer/ICustomerService.cs new file mode 100644 index 0000000..2eaf461 --- /dev/null +++ b/Webshop.Application/Services/Customer/ICustomerService.cs @@ -0,0 +1,16 @@ +// 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 + } +} diff --git a/Webshop.Application/Services/Customer/IOrderService.cs b/Webshop.Application/Services/Customer/IOrderService.cs new file mode 100644 index 0000000..df4b29e --- /dev/null +++ b/Webshop.Application/Services/Customer/IOrderService.cs @@ -0,0 +1,16 @@ +// 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 IOrderService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Customer/IReviewService.cs b/Webshop.Application/Services/Customer/IReviewService.cs new file mode 100644 index 0000000..314803e --- /dev/null +++ b/Webshop.Application/Services/Customer/IReviewService.cs @@ -0,0 +1,16 @@ +// 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 IReviewService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Customer/OrderService.cs b/Webshop.Application/Services/Customer/OrderService.cs new file mode 100644 index 0000000..c9d06b3 --- /dev/null +++ b/Webshop.Application/Services/Customer/OrderService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Customer +{ + public class OrderService : IOrderService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public OrderService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Customer/ReviewService.cs b/Webshop.Application/Services/Customer/ReviewService.cs new file mode 100644 index 0000000..5c3ab1d --- /dev/null +++ b/Webshop.Application/Services/Customer/ReviewService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Customer +{ + public class ReviewService : IReviewService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public ReviewService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Public/CategoryService.cs b/Webshop.Application/Services/Public/CategoryService.cs new file mode 100644 index 0000000..b672196 --- /dev/null +++ b/Webshop.Application/Services/Public/CategoryService.cs @@ -0,0 +1,17 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + + +namespace Webshop.Application.Services.Public +{ + public class CategoryService : ICategoryService + { + // Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories) + + // public CategoryService(IYourRepository repository) { } + + // Fügen Sie hier Service-Methoden hinzu + } +} diff --git a/Webshop.Application/Services/Public/ICategoryService.cs b/Webshop.Application/Services/Public/ICategoryService.cs new file mode 100644 index 0000000..52ab8a9 --- /dev/null +++ b/Webshop.Application/Services/Public/ICategoryService.cs @@ -0,0 +1,16 @@ +// 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.Public +{ + public interface ICategoryService + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Application/Services/Public/IProductService.cs b/Webshop.Application/Services/Public/IProductService.cs new file mode 100644 index 0000000..59d0c4a --- /dev/null +++ b/Webshop.Application/Services/Public/IProductService.cs @@ -0,0 +1,14 @@ +// src/Webshop.Application/Services/Public/IProductService.cs +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; // ProductDto + +namespace Webshop.Application.Services.Public +{ + public interface IProductService + { + Task> GetAllProductsAsync(); + // Task GetProductByIdAsync(Guid id); // Wenn Sie eine einzelne öffentliche Produktansicht brauchen + // Task CreateProductAsync(ProductDto productDto); // Nur wenn Public Service auch Erstellung erlaubt + } +} \ No newline at end of file diff --git a/Webshop.Application/Services/Public/ProductService.cs b/Webshop.Application/Services/Public/ProductService.cs index 42fa3ac..67d13c5 100644 --- a/Webshop.Application/Services/Public/ProductService.cs +++ b/Webshop.Application/Services/Public/ProductService.cs @@ -1,12 +1,15 @@ -// src/Webshop.Application/Services/Public/ProductService.cs -using Webshop.Application.DTOs; // ProductDto +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Application.DTOs; using Webshop.Domain.Interfaces; -using System.Collections.Generic; // Sicherstellen, dass für IEnumerable vorhanden using Webshop.Domain.Entities; + namespace Webshop.Application.Services.Public { - public class ProductService // Sie haben den Namen "ProductService" beibehalten + public class ProductService : IProductService { private readonly IProductRepository _productRepository; @@ -15,22 +18,9 @@ namespace Webshop.Application.Services.Public _productRepository = productRepository; } - public async Task> GetAllProductsAsync() - { - var productsFromDb = await _productRepository.GetAllProductsAsync(); - - return productsFromDb.Select(p => new ProductDto - { - Id = p.Id, - Name = p.Name, - Description = p.Description, - Price = p.Price, - SKU = p.SKU, - IsActive = p.IsActive, - IsInStock = p.IsInStock, - StockQuantity = p.StockQuantity, - ImageUrl = p.ImageUrl - }).ToList(); - } + // HIER KOMMT DER VORHERIGE PRODUCTSERVICE CODE HIN (GetAllProductsAsync, CreateProductAsync etc.) + // Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen: + public async Task> GetAllProductsAsync() { return new List(); } + public async Task CreateProductAsync(ProductDto productDto) { return null; } } -} \ No newline at end of file +} diff --git a/Webshop.Domain/Interfaces/ICategoryRepository.cs b/Webshop.Domain/Interfaces/ICategoryRepository.cs new file mode 100644 index 0000000..d577a2f --- /dev/null +++ b/Webshop.Domain/Interfaces/ICategoryRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface ICategoryRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/ICustomerRepository.cs b/Webshop.Domain/Interfaces/ICustomerRepository.cs new file mode 100644 index 0000000..81ddcfd --- /dev/null +++ b/Webshop.Domain/Interfaces/ICustomerRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface ICustomerRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/IDiscountRepository.cs b/Webshop.Domain/Interfaces/IDiscountRepository.cs new file mode 100644 index 0000000..b5429f8 --- /dev/null +++ b/Webshop.Domain/Interfaces/IDiscountRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface IDiscountRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/IOrderRepository.cs b/Webshop.Domain/Interfaces/IOrderRepository.cs new file mode 100644 index 0000000..64e1101 --- /dev/null +++ b/Webshop.Domain/Interfaces/IOrderRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface IOrderRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/IPaymentMethodRepository.cs b/Webshop.Domain/Interfaces/IPaymentMethodRepository.cs new file mode 100644 index 0000000..1ccf502 --- /dev/null +++ b/Webshop.Domain/Interfaces/IPaymentMethodRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface IPaymentMethodRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/IProductRepository.cs b/Webshop.Domain/Interfaces/IProductRepository.cs index 84e944b..b6a8e5b 100644 --- a/Webshop.Domain/Interfaces/IProductRepository.cs +++ b/Webshop.Domain/Interfaces/IProductRepository.cs @@ -1,15 +1,16 @@ -// src/Webshop.Domain/Interfaces/IProductRepository.cs -using Webshop.Domain.Entities; +// src/Webshop.Domain/Interfaces/IProductRepository.cs +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; // Product Entity namespace Webshop.Domain.Interfaces { public interface IProductRepository { - Task GetProductByIdAsync(Guid id); Task> GetAllProductsAsync(); + Task GetProductByIdAsync(Guid id); Task AddProductAsync(Product product); Task UpdateProductAsync(Product product); Task DeleteProductAsync(Guid id); - Task ProductExistsBySlugAsync(string slug); } } \ No newline at end of file diff --git a/Webshop.Domain/Interfaces/IReviewRepository.cs b/Webshop.Domain/Interfaces/IReviewRepository.cs new file mode 100644 index 0000000..bcc249b --- /dev/null +++ b/Webshop.Domain/Interfaces/IReviewRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface IReviewRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/ISettingRepository.cs b/Webshop.Domain/Interfaces/ISettingRepository.cs new file mode 100644 index 0000000..d048f8b --- /dev/null +++ b/Webshop.Domain/Interfaces/ISettingRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface ISettingRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/IShippingMethodRepository.cs b/Webshop.Domain/Interfaces/IShippingMethodRepository.cs new file mode 100644 index 0000000..51d3245 --- /dev/null +++ b/Webshop.Domain/Interfaces/IShippingMethodRepository.cs @@ -0,0 +1,14 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; + + +namespace Webshop.Domain.Interfaces +{ + public interface IShippingMethodRepository + { +// Fügen Sie hier Methodensignaturen hinzu + } +} diff --git a/Webshop.Domain/Interfaces/ISupplierRepository.cs b/Webshop.Domain/Interfaces/ISupplierRepository.cs index 8143532..2e1f316 100644 --- a/Webshop.Domain/Interfaces/ISupplierRepository.cs +++ b/Webshop.Domain/Interfaces/ISupplierRepository.cs @@ -1,5 +1,7 @@ -// src/Webshop.Domain/Interfaces/ISupplierRepository.cs -using Webshop.Domain.Entities; +// src/Webshop.Domain/Interfaces/ISupplierRepository.cs +using System.Collections.Generic; +using System.Threading.Tasks; +using Webshop.Domain.Entities; // Supplier Entity namespace Webshop.Domain.Interfaces { diff --git a/Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.Designer.cs b/Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.Designer.cs similarity index 99% rename from Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.Designer.cs rename to Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.Designer.cs index 5f5cc58..4e748af 100644 --- a/Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.Designer.cs +++ b/Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.Designer.cs @@ -12,8 +12,8 @@ using Webshop.Infrastructure.Data; namespace Webshop.Infrastructure.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20250723113024_InitialCreate")] - partial class InitialCreate + [Migration("20250723190813_InititalCreate")] + partial class InititalCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.cs b/Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.cs similarity index 99% rename from Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.cs rename to Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.cs index d58ae5b..b6d2d75 100644 --- a/Webshop.Infrastructure/Migrations/20250723113024_InitialCreate.cs +++ b/Webshop.Infrastructure/Migrations/20250723190813_InititalCreate.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Webshop.Infrastructure.Migrations { /// - public partial class InitialCreate : Migration + public partial class InititalCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Webshop.Infrastructure/Repositories/CategoryRepository.cs b/Webshop.Infrastructure/Repositories/CategoryRepository.cs new file mode 100644 index 0000000..31eadfc --- /dev/null +++ b/Webshop.Infrastructure/Repositories/CategoryRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class CategoryRepository : ICategoryRepository + { + private readonly ApplicationDbContext _context; + + public CategoryRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/CustomerRepository.cs b/Webshop.Infrastructure/Repositories/CustomerRepository.cs new file mode 100644 index 0000000..04984a8 --- /dev/null +++ b/Webshop.Infrastructure/Repositories/CustomerRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class CustomerRepository : ICustomerRepository + { + private readonly ApplicationDbContext _context; + + public CustomerRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/DiscountRepository.cs b/Webshop.Infrastructure/Repositories/DiscountRepository.cs new file mode 100644 index 0000000..8fc24c5 --- /dev/null +++ b/Webshop.Infrastructure/Repositories/DiscountRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class DiscountRepository : IDiscountRepository + { + private readonly ApplicationDbContext _context; + + public DiscountRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/OrderRepository.cs b/Webshop.Infrastructure/Repositories/OrderRepository.cs new file mode 100644 index 0000000..6985d7b --- /dev/null +++ b/Webshop.Infrastructure/Repositories/OrderRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class OrderRepository : IOrderRepository + { + private readonly ApplicationDbContext _context; + + public OrderRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/PaymentMethodRepository.cs b/Webshop.Infrastructure/Repositories/PaymentMethodRepository.cs new file mode 100644 index 0000000..29a21f2 --- /dev/null +++ b/Webshop.Infrastructure/Repositories/PaymentMethodRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class PaymentMethodRepository : IPaymentMethodRepository + { + private readonly ApplicationDbContext _context; + + public PaymentMethodRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/ProductRepository.cs b/Webshop.Infrastructure/Repositories/ProductRepository.cs index 05bc589..4985af2 100644 --- a/Webshop.Infrastructure/Repositories/ProductRepository.cs +++ b/Webshop.Infrastructure/Repositories/ProductRepository.cs @@ -1,21 +1,25 @@ -// src/Webshop.Infrastructure/Repositories/ProductRepository.cs -using Microsoft.EntityFrameworkCore; +// src/Webshop.Infrastructure/Repositories/ProductRepository.cs +using Microsoft.EntityFrameworkCore; // Wichtig für ToListAsync, FindAsync etc. using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; using Webshop.Infrastructure.Data; +using System; // Für Guid +using System.Collections.Generic; +using System.Threading.Tasks; namespace Webshop.Infrastructure.Repositories { - public class ProductRepository : IProductRepository + public class ProductRepository : IProductRepository // ACHTUNG: Hier muss das Interface stehen { private readonly ApplicationDbContext _context; - // Wir lassen uns den DbContext per Dependency Injection geben public ProductRepository(ApplicationDbContext context) { _context = context; } + // --- IMPLEMENTIERUNG DER IProductRepository METHODEN --- + public async Task> GetAllProductsAsync() { return await _context.Products.ToListAsync(); @@ -28,13 +32,8 @@ namespace Webshop.Infrastructure.Repositories public async Task AddProductAsync(Product product) { - await _context.Products.AddAsync(product); - await _context.SaveChangesAsync(); - } - - public async Task ProductExistsBySlugAsync(string slug) - { - return await _context.Products.AnyAsync(p => p.Slug == slug); + _context.Products.Add(product); + await _context.SaveChangesAsync(); // Änderungen in der DB speichern } public async Task UpdateProductAsync(Product product) @@ -45,11 +44,11 @@ namespace Webshop.Infrastructure.Repositories public async Task DeleteProductAsync(Guid id) { - var product = await _context.Products.FindAsync(id); + var product = await _context.Products.FindAsync(id); // Produkt zuerst finden if (product != null) { - _context.Products.Remove(product); - await _context.SaveChangesAsync(); + _context.Products.Remove(product); // Produkt entfernen + await _context.SaveChangesAsync(); // Änderungen speichern } } } diff --git a/Webshop.Infrastructure/Repositories/ReviewRepository.cs b/Webshop.Infrastructure/Repositories/ReviewRepository.cs new file mode 100644 index 0000000..85b2b0f --- /dev/null +++ b/Webshop.Infrastructure/Repositories/ReviewRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class ReviewRepository : IReviewRepository + { + private readonly ApplicationDbContext _context; + + public ReviewRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/SettingRepository.cs b/Webshop.Infrastructure/Repositories/SettingRepository.cs new file mode 100644 index 0000000..0911508 --- /dev/null +++ b/Webshop.Infrastructure/Repositories/SettingRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class SettingRepository : ISettingRepository + { + private readonly ApplicationDbContext _context; + + public SettingRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/ShippingMethodRepository.cs b/Webshop.Infrastructure/Repositories/ShippingMethodRepository.cs new file mode 100644 index 0000000..b7ac008 --- /dev/null +++ b/Webshop.Infrastructure/Repositories/ShippingMethodRepository.cs @@ -0,0 +1,29 @@ +// Auto-generiert von CreateWebshopFiles.ps1 +using Microsoft.EntityFrameworkCore; +using Webshop.Domain.Entities; +using Webshop.Domain.Interfaces; +using Webshop.Infrastructure.Data; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Webshop.Infrastructure.Repositories +{ + public class ShippingMethodRepository : IShippingMethodRepository + { + private readonly ApplicationDbContext _context; + + public ShippingMethodRepository(ApplicationDbContext context) + { + _context = context; + } + + // Fügen Sie hier Repository-Methoden hinzu + // Beispiel: + // public async Task> GetAllAsync() { return await _context.Set().ToListAsync(); } + // public async Task GetByIdAsync(Guid id) { return await _context.Set().FindAsync(id); } + // public async Task AddAsync(T entity) { _context.Set().Add(entity); await _context.SaveChangesAsync(); } + // public async Task UpdateAsync(T entity) { _context.Set().Update(entity); await _context.SaveChangesAsync(); } + // public async Task DeleteAsync(Guid id) { var entity = await _context.Set().FindAsync(id); if (entity != null) { _context.Set().Remove(entity); await _context.SaveChangesAsync(); } } + } +} diff --git a/Webshop.Infrastructure/Repositories/SupplierRepository.cs b/Webshop.Infrastructure/Repositories/SupplierRepository.cs index 19c4e59..5074a5a 100644 --- a/Webshop.Infrastructure/Repositories/SupplierRepository.cs +++ b/Webshop.Infrastructure/Repositories/SupplierRepository.cs @@ -1,12 +1,16 @@ -// src/Webshop.Infrastructure/Repositories/SupplierRepository.cs -using Microsoft.EntityFrameworkCore; // Für ToListAsync +// src/Webshop.Infrastructure/Repositories/SupplierRepository.cs +// Auto-generiert von CreateWebshopFiles.ps1 (aktualisiert um Implementierungen) +using Microsoft.EntityFrameworkCore; // Wichtig für ToListAsync, FindAsync etc. using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; using Webshop.Infrastructure.Data; +using System; // Für Guid +using System.Collections.Generic; +using System.Threading.Tasks; namespace Webshop.Infrastructure.Repositories { - public class SupplierRepository : ISupplierRepository + public class SupplierRepository : ISupplierRepository // Hier muss das Interface stehen { private readonly ApplicationDbContext _context; @@ -15,6 +19,8 @@ namespace Webshop.Infrastructure.Repositories _context = context; } + // --- IMPLEMENTIERUNG DER ISupplierRepository METHODEN --- + public async Task> GetAllSuppliersAsync() { return await _context.Suppliers.ToListAsync(); @@ -28,7 +34,7 @@ namespace Webshop.Infrastructure.Repositories public async Task AddSupplierAsync(Supplier supplier) { _context.Suppliers.Add(supplier); - await _context.SaveChangesAsync(); + await _context.SaveChangesAsync(); // Änderungen in der DB speichern } public async Task UpdateSupplierAsync(Supplier supplier) @@ -39,11 +45,11 @@ namespace Webshop.Infrastructure.Repositories public async Task DeleteSupplierAsync(Guid id) { - var supplier = await _context.Suppliers.FindAsync(id); + var supplier = await _context.Suppliers.FindAsync(id); // Lieferant zuerst finden if (supplier != null) { - _context.Suppliers.Remove(supplier); - await _context.SaveChangesAsync(); + _context.Suppliers.Remove(supplier); // Lieferant entfernen + await _context.SaveChangesAsync(); // Änderungen speichern } } }