settings
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
// src/Webshop.Application/DTOs/Settings/SettingDto.cs
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace Webshop.Application.DTOs
|
||||
namespace Webshop.Application.DTOs.Settings
|
||||
{
|
||||
public class SettingDto
|
||||
{
|
||||
[Required]
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public string? Value { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public DateTimeOffset LastModifiedDate { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public string? Group { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,53 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using System;
|
||||
// src/Webshop.Application/Services/Admin/AdminSettingService.cs
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Settings;
|
||||
using Webshop.Application.Services.Admin.Interfaces;
|
||||
|
||||
using Webshop.Domain.Interfaces;
|
||||
|
||||
namespace Webshop.Application.Services.Admin
|
||||
{
|
||||
public class AdminSettingService : IAdminSettingService
|
||||
{
|
||||
// Fügen Sie hier Abhängigkeiten per Dependency Injection hinzu (z.B. Repositories)
|
||||
private readonly ISettingRepository _settingRepository;
|
||||
|
||||
// public AdminSettingService(IYourRepository repository) { }
|
||||
public AdminSettingService(ISettingRepository settingRepository)
|
||||
{
|
||||
_settingRepository = settingRepository;
|
||||
}
|
||||
|
||||
// Fügen Sie hier Service-Methoden hinzu
|
||||
public async Task<Dictionary<string, List<SettingDto>>> GetAllGroupedAsync()
|
||||
{
|
||||
var settings = await _settingRepository.GetAllAsync();
|
||||
|
||||
return settings
|
||||
.GroupBy(s => s.Group ?? "Uncategorized")
|
||||
.ToDictionary(
|
||||
g => g.Key,
|
||||
g => g.Select(s => new SettingDto
|
||||
{
|
||||
Key = s.Key,
|
||||
Value = s.Value,
|
||||
Description = s.Description,
|
||||
IsActive = s.IsActive,
|
||||
Group = s.Group
|
||||
}).ToList()
|
||||
);
|
||||
}
|
||||
|
||||
public async Task UpdateSettingsAsync(List<SettingDto> settings)
|
||||
{
|
||||
foreach (var settingDto in settings)
|
||||
{
|
||||
var setting = await _settingRepository.GetByKeyAsync(settingDto.Key);
|
||||
if (setting != null)
|
||||
{
|
||||
setting.Value = settingDto.Value;
|
||||
setting.IsActive = settingDto.IsActive; // Auch IsActive aktualisieren
|
||||
await _settingRepository.UpdateAsync(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using System;
|
||||
// src/Webshop.Application/Services/Admin/Interfaces/IAdminSettingService.cs
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Application.DTOs.Auth;
|
||||
using Webshop.Application.DTOs.Users;
|
||||
|
||||
using Webshop.Application.DTOs.Settings;
|
||||
|
||||
namespace Webshop.Application.Services.Admin.Interfaces
|
||||
{
|
||||
public interface IAdminSettingService
|
||||
{
|
||||
// Fügen Sie hier Methodensignaturen hinzu
|
||||
Task<Dictionary<string, List<SettingDto>>> GetAllGroupedAsync();
|
||||
Task UpdateSettingsAsync(List<SettingDto> settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user