try
This commit is contained in:
939
CreateWebshopFiles.ps1
Normal file
939
CreateWebshopFiles.ps1
Normal file
@@ -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<IActionResult> 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<IActionResult> 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<IActionResult> 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<ActionResult<IEnumerable<ProductDto>>> 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<ActionResult<IEnumerable<AdminProductDto>>> GetAdminProducts()
|
||||
{
|
||||
var products = await _adminProductService.GetAllAdminProductsAsync();
|
||||
return Ok(products);
|
||||
}
|
||||
|
||||
[HttpGet(""{id}"")]
|
||||
public async Task<ActionResult<AdminProductDto>> GetAdminProduct(Guid id)
|
||||
{
|
||||
var product = await _adminProductService.GetAdminProductByIdAsync(id);
|
||||
if (product == null) return NotFound();
|
||||
return Ok(product);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<AdminProductDto>> 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<IActionResult> 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<IActionResult> 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<ActionResult<IEnumerable<UserDto>>> GetAllUsers()
|
||||
{
|
||||
var users = await _adminUserService.GetAllUsersAsync();
|
||||
return Ok(users);
|
||||
}
|
||||
|
||||
[HttpGet(""{userId}"")]
|
||||
public async Task<ActionResult<UserDto>> 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<ActionResult<IEnumerable<SupplierDto>>> GetAllSuppliers()
|
||||
{
|
||||
var suppliers = await _adminSupplierService.GetAllSuppliersAsync();
|
||||
return Ok(suppliers);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<SupplierDto>> 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<ActionResult<SupplierDto>> 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<IActionResult> 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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().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<IdentityUser> _userManager;
|
||||
private readonly SignInManager<IdentityUser> _signInManager;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly RoleManager<IdentityRole> _roleManager;
|
||||
|
||||
public AuthService(
|
||||
UserManager<IdentityUser> userManager,
|
||||
SignInManager<IdentityUser> signInManager,
|
||||
IConfiguration configuration,
|
||||
RoleManager<IdentityRole> 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<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; }
|
||||
public async Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; }
|
||||
public async Task<AuthResponseDto> LoginAdminAsync(LoginRequestDto request) { return new AuthResponseDto { IsAuthSuccessful = false, ErrorMessage = ""Not implemented"" }; }
|
||||
private Task<string> GenerateJwtToken(IdentityUser user, IList<string> 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<IEnumerable<AdminProductDto>> GetAllAdminProductsAsync() { return new List<AdminProductDto>(); }
|
||||
public async Task<AdminProductDto?> GetAdminProductByIdAsync(Guid id) { return null; }
|
||||
public async Task<AdminProductDto> CreateAdminProductAsync(AdminProductDto productDto) { return null; }
|
||||
public async Task<bool> UpdateAdminProductAsync(AdminProductDto productDto) { return false; }
|
||||
public async Task<bool> 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<IdentityUser> _userManager;
|
||||
|
||||
public AdminUserService(UserManager<IdentityUser> 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<IEnumerable<UserDto>> GetAllUsersAsync() { return new List<UserDto>(); }
|
||||
public async Task<UserDto?> 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<IEnumerable<ProductDto>> GetAllProductsAsync() { return new List<ProductDto>(); }
|
||||
public async Task<ProductDto> 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<IEnumerable<SupplierDto>> GetAllSuppliersAsync() { return new List<SupplierDto>(); }
|
||||
public async Task<SupplierDto?> GetSupplierByIdAsync(Guid id) { return null; }
|
||||
public async Task<SupplierDto> 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<Product?> GetProductByIdAsync(Guid id);
|
||||
Task<IEnumerable<Product>> GetAllProductsAsync();
|
||||
Task AddProductAsync(Product product);
|
||||
Task UpdateProductAsync(Product product);
|
||||
Task DeleteProductAsync(Guid id);
|
||||
"@
|
||||
} elseif ($nameWithoutExtension -eq "ISupplierRepository") {
|
||||
$fileContentBody = @"
|
||||
Task<IEnumerable<Supplier>> GetAllSuppliersAsync();
|
||||
Task<Supplier?> 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<AuthResponseDto> RegisterUserAsync(RegisterRequestDto request);
|
||||
Task<AuthResponseDto> LoginUserAsync(LoginRequestDto request);
|
||||
Task<AuthResponseDto> 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<string> Roles { get; set; } = new List<string>();
|
||||
"@
|
||||
} 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<string> Roles { get; set; } = new List<string>();
|
||||
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<OrderItemDto> OrderItems { get; set; } = new List<OrderItemDto>();
|
||||
"@
|
||||
} 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<CreateOrderItemDto> Items { get; set; } = new List<CreateOrderItemDto>();
|
||||
"@
|
||||
} 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
|
||||
18
Webshop.Api/Controllers/Admin/AdminCategoriesController.cs
Normal file
18
Webshop.Api/Controllers/Admin/AdminCategoriesController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Admin/AdminDiscountsController.cs
Normal file
18
Webshop.Api/Controllers/Admin/AdminDiscountsController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Admin/AdminOrdersController.cs
Normal file
18
Webshop.Api/Controllers/Admin/AdminOrdersController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<ActionResult<IEnumerable<AdminProductDto>>> GetAdminProducts()
|
||||
{
|
||||
var products = await _adminProductService.GetAllAdminProductsAsync();
|
||||
return Ok(products);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")] // /api/v1/admin/products/{id}
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<AdminProductDto>> 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<ActionResult<AdminProductDto>> 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<IActionResult> 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<IActionResult> DeleteAdminProduct(Guid id)
|
||||
{
|
||||
var success = await _adminProductService.DeleteAdminProductAsync(id);
|
||||
|
||||
18
Webshop.Api/Controllers/Admin/AdminSettingsController.cs
Normal file
18
Webshop.Api/Controllers/Admin/AdminSettingsController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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<ActionResult<IEnumerable<UserDto>>> GetAllUsers()
|
||||
{
|
||||
var users = await _adminUserService.GetAllUsersAsync();
|
||||
return Ok(users);
|
||||
}
|
||||
|
||||
[HttpGet("{userId}")] // /api/v1/admin/users/{userId}
|
||||
[HttpGet("{userId}")]
|
||||
public async Task<ActionResult<UserDto>> 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
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Customer/CheckoutController.cs
Normal file
18
Webshop.Api/Controllers/Customer/CheckoutController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<IActionResult> 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)." });
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Customer/ProfileController.cs
Normal file
18
Webshop.Api/Controllers/Customer/ProfileController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Customer/ReviewsController.cs
Normal file
18
Webshop.Api/Controllers/Customer/ReviewsController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Public/CategoriesController.cs
Normal file
18
Webshop.Api/Controllers/Public/CategoriesController.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<ActionResult<IEnumerable<ProductDto>>> 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.
|
||||
}
|
||||
}
|
||||
20
Webshop.Application/DTOs/AddressDto.cs
Normal file
20
Webshop.Application/DTOs/AddressDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
20
Webshop.Application/DTOs/CategoryDto.cs
Normal file
20
Webshop.Application/DTOs/CategoryDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
19
Webshop.Application/DTOs/CreateCategoryDto.cs
Normal file
19
Webshop.Application/DTOs/CreateCategoryDto.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
20
Webshop.Application/DTOs/CreateOrderDto.cs
Normal file
20
Webshop.Application/DTOs/CreateOrderDto.cs
Normal file
@@ -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<CreateOrderItemDto> Items { get; set; } = new List<CreateOrderItemDto>();
|
||||
}
|
||||
}
|
||||
15
Webshop.Application/DTOs/CreateOrderItemDto.cs
Normal file
15
Webshop.Application/DTOs/CreateOrderItemDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/DTOs/CreateReviewDto.cs
Normal file
16
Webshop.Application/DTOs/CreateReviewDto.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
20
Webshop.Application/DTOs/CustomerDto.cs
Normal file
20
Webshop.Application/DTOs/CustomerDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
24
Webshop.Application/DTOs/DiscountDto.cs
Normal file
24
Webshop.Application/DTOs/DiscountDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
27
Webshop.Application/DTOs/OrderDetailDto.cs
Normal file
27
Webshop.Application/DTOs/OrderDetailDto.cs
Normal file
@@ -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<OrderItemDto> OrderItems { get; set; } = new List<OrderItemDto>();
|
||||
}
|
||||
}
|
||||
21
Webshop.Application/DTOs/OrderItemDto.cs
Normal file
21
Webshop.Application/DTOs/OrderItemDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
21
Webshop.Application/DTOs/OrderSummaryDto.cs
Normal file
21
Webshop.Application/DTOs/OrderSummaryDto.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
19
Webshop.Application/DTOs/PaymentMethodDto.cs
Normal file
19
Webshop.Application/DTOs/PaymentMethodDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
21
Webshop.Application/DTOs/ProductVariantDto.cs
Normal file
21
Webshop.Application/DTOs/ProductVariantDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
20
Webshop.Application/DTOs/ReviewDto.cs
Normal file
20
Webshop.Application/DTOs/ReviewDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/DTOs/SettingDto.cs
Normal file
16
Webshop.Application/DTOs/SettingDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
19
Webshop.Application/DTOs/ShippingMethodDto.cs
Normal file
19
Webshop.Application/DTOs/ShippingMethodDto.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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<string> Roles { get; set; } = new List<string>();
|
||||
public DateTimeOffset CreatedDate { get; set; } // Placeholder, as IdentityUser doesn't have it directly
|
||||
public DateTimeOffset CreatedDate { get; set; }
|
||||
public bool EmailConfirmed { get; set; }
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Admin/AdminCategoryService.cs
Normal file
17
Webshop.Application/Services/Admin/AdminCategoryService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Admin/AdminDiscountService.cs
Normal file
17
Webshop.Application/Services/Admin/AdminDiscountService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Admin/AdminOrderService.cs
Normal file
17
Webshop.Application/Services/Admin/AdminOrderService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<AdminProductDto>> 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<AdminProductDto?> 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<AdminProductDto> 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<bool> 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<bool> 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<IEnumerable<AdminProductDto>> GetAllAdminProductsAsync() { return new List<AdminProductDto>(); }
|
||||
public async Task<AdminProductDto?> GetAdminProductByIdAsync(Guid id) { return null; }
|
||||
public async Task<AdminProductDto> CreateAdminProductAsync(AdminProductDto productDto) { return null; }
|
||||
public async Task<bool> UpdateAdminProductAsync(AdminProductDto productDto) { return false; }
|
||||
public async Task<bool> DeleteAdminProductAsync(Guid id) { return false; }
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Admin/AdminSettingService.cs
Normal file
17
Webshop.Application/Services/Admin/AdminSettingService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<SupplierDto>> 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<SupplierDto?> 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<SupplierDto> 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<IEnumerable<SupplierDto>> GetAllSuppliersAsync() { return new List<SupplierDto>(); }
|
||||
public async Task<SupplierDto?> GetSupplierByIdAsync(Guid id) { return null; }
|
||||
public async Task<SupplierDto> CreateSupplierAsync(SupplierDto supplierDto) { return null; }
|
||||
}
|
||||
}
|
||||
@@ -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<IdentityUser> _userManager;
|
||||
|
||||
@@ -15,47 +18,9 @@ namespace Webshop.Application.Services.Admin
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<UserDto>> GetAllUsersAsync()
|
||||
{
|
||||
var users = await _userManager.Users.ToListAsync();
|
||||
|
||||
var userDtos = new List<UserDto>();
|
||||
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<UserDto?> 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<IEnumerable<UserDto>> GetAllUsersAsync() { return new List<UserDto>(); }
|
||||
public async Task<UserDto?> GetUserByIdAsync(string userId) { return null; }
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminCategoryService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminCategoryService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminDiscountService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminDiscountService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminOrderService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminOrderService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminProductService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminProductService.cs
Normal file
@@ -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<IEnumerable<AdminProductDto>> GetAllAdminProductsAsync();
|
||||
Task<AdminProductDto?> GetAdminProductByIdAsync(Guid id);
|
||||
Task<AdminProductDto> CreateAdminProductAsync(AdminProductDto productDto);
|
||||
Task<bool> UpdateAdminProductAsync(AdminProductDto productDto);
|
||||
Task<bool> DeleteAdminProductAsync(Guid id);
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminSettingService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminSettingService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Admin/IAdminSupplierService.cs
Normal file
16
Webshop.Application/Services/Admin/IAdminSupplierService.cs
Normal file
@@ -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<IEnumerable<SupplierDto>> GetAllSuppliersAsync();
|
||||
Task<SupplierDto?> GetSupplierByIdAsync(Guid id);
|
||||
Task<SupplierDto> CreateSupplierAsync(SupplierDto supplierDto);
|
||||
// Task<bool> UpdateSupplierAsync(SupplierDto supplierDto); // Beispiel für zukünftige Methode
|
||||
// Task<bool> DeleteSupplierAsync(Guid id); // Beispiel für zukünftige Methode
|
||||
}
|
||||
}
|
||||
15
Webshop.Application/Services/Admin/IAdminUserService.cs
Normal file
15
Webshop.Application/Services/Admin/IAdminUserService.cs
Normal file
@@ -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<IEnumerable<UserDto>> GetAllUsersAsync();
|
||||
Task<UserDto?> GetUserByIdAsync(string userId);
|
||||
// Task<bool> UpdateUserRolesAsync(string userId, List<string> newRoles); // Beispiel für zukünftige Methode
|
||||
// Task<bool> DeleteUserAsync(string userId); // Beispiel für zukünftige Methode
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Customer/CheckoutService.cs
Normal file
17
Webshop.Application/Services/Customer/CheckoutService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Customer/CustomerService.cs
Normal file
17
Webshop.Application/Services/Customer/CustomerService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Customer/ICheckoutService.cs
Normal file
16
Webshop.Application/Services/Customer/ICheckoutService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Customer/ICustomerService.cs
Normal file
16
Webshop.Application/Services/Customer/ICustomerService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Customer/IOrderService.cs
Normal file
16
Webshop.Application/Services/Customer/IOrderService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Customer/IReviewService.cs
Normal file
16
Webshop.Application/Services/Customer/IReviewService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Customer/OrderService.cs
Normal file
17
Webshop.Application/Services/Customer/OrderService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Customer/ReviewService.cs
Normal file
17
Webshop.Application/Services/Customer/ReviewService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Services/Public/CategoryService.cs
Normal file
17
Webshop.Application/Services/Public/CategoryService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
16
Webshop.Application/Services/Public/ICategoryService.cs
Normal file
16
Webshop.Application/Services/Public/ICategoryService.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Application/Services/Public/IProductService.cs
Normal file
14
Webshop.Application/Services/Public/IProductService.cs
Normal file
@@ -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<IEnumerable<ProductDto>> GetAllProductsAsync();
|
||||
// Task<ProductDto?> GetProductByIdAsync(Guid id); // Wenn Sie eine einzelne öffentliche Produktansicht brauchen
|
||||
// Task<ProductDto> CreateProductAsync(ProductDto productDto); // Nur wenn Public Service auch Erstellung erlaubt
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<ProductDto>> 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<IEnumerable<ProductDto>> GetAllProductsAsync() { return new List<ProductDto>(); }
|
||||
public async Task<ProductDto> CreateProductAsync(ProductDto productDto) { return null; }
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/ICategoryRepository.cs
Normal file
14
Webshop.Domain/Interfaces/ICategoryRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/ICustomerRepository.cs
Normal file
14
Webshop.Domain/Interfaces/ICustomerRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/IDiscountRepository.cs
Normal file
14
Webshop.Domain/Interfaces/IDiscountRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/IOrderRepository.cs
Normal file
14
Webshop.Domain/Interfaces/IOrderRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/IPaymentMethodRepository.cs
Normal file
14
Webshop.Domain/Interfaces/IPaymentMethodRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<Product?> GetProductByIdAsync(Guid id);
|
||||
Task<IEnumerable<Product>> GetAllProductsAsync();
|
||||
Task<Product?> GetProductByIdAsync(Guid id);
|
||||
Task AddProductAsync(Product product);
|
||||
Task UpdateProductAsync(Product product);
|
||||
Task DeleteProductAsync(Guid id);
|
||||
Task<bool> ProductExistsBySlugAsync(string slug);
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/IReviewRepository.cs
Normal file
14
Webshop.Domain/Interfaces/IReviewRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/ISettingRepository.cs
Normal file
14
Webshop.Domain/Interfaces/ISettingRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
14
Webshop.Domain/Interfaces/IShippingMethodRepository.cs
Normal file
14
Webshop.Domain/Interfaces/IShippingMethodRepository.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class InititalCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
29
Webshop.Infrastructure/Repositories/CategoryRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/CategoryRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
29
Webshop.Infrastructure/Repositories/CustomerRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/CustomerRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
29
Webshop.Infrastructure/Repositories/DiscountRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/DiscountRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
29
Webshop.Infrastructure/Repositories/OrderRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/OrderRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<Product>> 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<bool> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
29
Webshop.Infrastructure/Repositories/ReviewRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/ReviewRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
29
Webshop.Infrastructure/Repositories/SettingRepository.cs
Normal file
29
Webshop.Infrastructure/Repositories/SettingRepository.cs
Normal file
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
|
||||
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
|
||||
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
|
||||
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
|
||||
}
|
||||
}
|
||||
@@ -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<IEnumerable<Supplier>> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user