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

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

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

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

View File

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

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

View File

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

View File

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

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

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

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

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

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

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

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