This commit is contained in:
Tizian.Breuch
2025-07-23 21:08:30 +02:00
parent d20a6d6ae6
commit ce69373adb
85 changed files with 2311 additions and 332 deletions

View File

@@ -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)

View File

@@ -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)

View 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(); } }
}
}

View 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(); } }
}
}

View 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(); } }
}
}

View 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(); } }
}
}

View 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 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(); } }
}
}

View File

@@ -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
}
}
}

View 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(); } }
}
}

View 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(); } }
}
}

View 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 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(); } }
}
}

View File

@@ -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
}
}
}