AccountingNext/Schaad.Accounting.Services/SettingsService.cs
Claudio Schaad 1a3d93e0e3 Remove dead and unused code
- CSS: drop the Bootstrap template leftovers (NavMenu.razor.css, most of
  MainLayout.razor.css, button/form rules in app.css) and the copied
  Fluent demo rules in BankTransactions.razor.css.
- Bootstrap: keep only bootstrap.min.css (+ map); 42 unused files removed.
- Credit-card statement import, never wired into the Blazor UI: service
  methods, GetCreditCardStatementPath, DI registrations for
  ICreditCardStatementService/IPdfParsingService, FreeSpire.PDF.
- CSV export (GetTransactionListCsvAsync), only called from tests.
- Split predefinitions: model, repository and the JSON editor entry.
- Unused members: TrySetYear, GetUploadPath (+ DataFolders.Uploads),
  GetClasses; unused usings, fields and parameters.
- Home.razor.css -> PendingBookings.razor.css: the pending-bookings table
  moved there in "PR U-10" and had lost its styling since.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 22:46:08 +01:00

94 lines
No EOL
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Schaad.Accounting.Datasets;
using Schaad.Accounting.Interfaces;
namespace Schaad.Accounting.Services
{
public class SettingsService : ISettingsService
{
private readonly SettingsDataset settingsDataset;
private string mandator;
private int year = DateTime.Now.Year;
public SettingsService(SettingsDataset settingsDataset)
{
this.settingsDataset = settingsDataset;
this.mandator = settingsDataset.DefaultMandator;
}
public int GetYear()
{
return year;
}
public void SetYear(int year)
{
this.year = year;
}
public string GetMandator()
{
return mandator;
}
/// <summary>
/// Mandators that have a folder for the given year.
/// </summary>
public IReadOnlyList<string> GetMandators(int year)
{
var dataPath = GetSettings().DataPath;
if (Directory.Exists(dataPath) == false)
{
return [];
}
return Directory.GetDirectories(dataPath)
.Where(d => Directory.Exists(Path.Combine(d, year.ToString())))
.Select(Path.GetFileName)
.Where(name => !DataFolders.IsReserved(name))
.ToList();
}
public void SetMandator(string mandator)
{
this.mandator = mandator;
}
public string GetBackupFilePath()
{
var backupPath = EnsureDirectory(Path.Combine(GetSettings().DataPath, DataFolders.Backup, mandator, year.ToString()));
return Path.Combine(backupPath, DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip");
}
public string GetDbPath()
{
return EnsureDirectory(Path.Combine(GetSettings().DataPath, mandator, year.ToString()));
}
public string GetLastYearDbPath()
{
return EnsureDirectory(Path.Combine(GetSettings().DataPath, mandator, (year - 1).ToString()));
}
public string GetMandatorPath()
{
return EnsureDirectory(Path.Combine(GetSettings().DataPath, mandator));
}
public SettingsDataset GetSettings()
{
return settingsDataset;
}
private static string EnsureDirectory(string path)
{
if (Directory.Exists(path) == false)
{
Directory.CreateDirectory(path);
}
return path;
}
}
}