Refactor Api-Client
Add Exceptionhandler, AlertService JSON-Converter AppSettings via DI Reformat Code
This commit is contained in:
11
Jugenddienst Stunden/Interfaces/IAlertService.cs
Normal file
11
Jugenddienst Stunden/Interfaces/IAlertService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jugenddienst_Stunden.Interfaces;
|
||||
internal interface IAlertService {
|
||||
event EventHandler<string> AlertRaised;
|
||||
void Raise(string message);
|
||||
}
|
||||
10
Jugenddienst Stunden/Interfaces/IApiClient.cs
Normal file
10
Jugenddienst Stunden/Interfaces/IApiClient.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Jugenddienst_Stunden.Interfaces;
|
||||
|
||||
internal interface IApiClient {
|
||||
Task<T> GetAsync<T>(string path, IDictionary<string, string?>? query = null, CancellationToken ct = default);
|
||||
|
||||
Task<T> SendAsync<T>(HttpMethod method, string path, object? body = null,
|
||||
IDictionary<string, string?>? query = null, CancellationToken ct = default);
|
||||
|
||||
Task DeleteAsync(string path, IDictionary<string, string?>? query = null, CancellationToken ct = default);
|
||||
}
|
||||
10
Jugenddienst Stunden/Interfaces/IAppSettings.cs
Normal file
10
Jugenddienst Stunden/Interfaces/IAppSettings.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Jugenddienst_Stunden.Interfaces;
|
||||
|
||||
public interface IAppSettings {
|
||||
string ApiUrl { get; set; }
|
||||
string ApiKey { get; set; }
|
||||
|
||||
int EmployeeId { get; set; }
|
||||
string Name { get; set; }
|
||||
string Surname { get; set; }
|
||||
}
|
||||
@@ -6,12 +6,12 @@ namespace Jugenddienst_Stunden.Interfaces;
|
||||
/// Repository‑Schnittstelle für Datenzugriff (API/Storage) rund um Stunden.
|
||||
/// </summary>
|
||||
internal interface IHoursRepository {
|
||||
Task<BaseResponse> LoadBase(string query);
|
||||
Task<Settings> LoadSettings();
|
||||
Task<Hours> LoadData();
|
||||
Task<User> LoadUser(string apiKey);
|
||||
Task<List<DayTime>> LoadDay(DateTime date);
|
||||
Task<DayTime> LoadEntry(int id);
|
||||
Task<DayTime> SaveEntry(DayTime stunde);
|
||||
Task DeleteEntry(DayTime stunde);
|
||||
}
|
||||
Task<BaseResponse> LoadBase(string query);
|
||||
Task<Settings> LoadSettings();
|
||||
Task<Hours> LoadData();
|
||||
Task<User> LoadUser(string apiKey);
|
||||
Task<List<DayTime>> LoadDay(DateTime date);
|
||||
Task<DayTime> LoadEntry(int id);
|
||||
Task<DayTime> SaveEntry(DayTime stunde);
|
||||
Task DeleteEntry(DayTime stunde);
|
||||
}
|
||||
@@ -5,12 +5,12 @@ namespace Jugenddienst_Stunden.Interfaces;
|
||||
/// <summary>
|
||||
/// Fachlicher Service für Stunden – konsumiert Repository und stellt VM‑freundliche Methoden bereit.
|
||||
/// </summary>
|
||||
internal interface IHoursService {
|
||||
Task<(Hours hours, Settings settings)> GetMonthSummaryAsync(DateTime monthDate);
|
||||
Task<(List<DayTime> dayTimes, Settings settings)> GetDayWithSettingsAsync(DateTime date);
|
||||
Task<List<DayTime>> GetDayRangeAsync(DateTime from, DateTime to);
|
||||
Task<Settings> GetSettingsAsync();
|
||||
Task<DayTime> GetEntryAsync(int id);
|
||||
Task<DayTime> SaveEntryAsync(DayTime stunde);
|
||||
Task DeleteEntryAsync(DayTime stunde);
|
||||
}
|
||||
public interface IHoursService {
|
||||
Task<(Hours hours, Settings settings)> GetMonthSummaryAsync(DateTime monthDate);
|
||||
Task<(List<DayTime> dayTimes, Settings settings)> GetDayWithSettingsAsync(DateTime date);
|
||||
Task<List<DayTime>> GetDayRangeAsync(DateTime from, DateTime to);
|
||||
Task<Settings> GetSettingsAsync();
|
||||
Task<DayTime> GetEntryAsync(int id);
|
||||
Task<DayTime> SaveEntryAsync(DayTime stunde);
|
||||
Task DeleteEntryAsync(DayTime stunde);
|
||||
}
|
||||
5
Jugenddienst Stunden/Interfaces/ITokenProvider.cs
Normal file
5
Jugenddienst Stunden/Interfaces/ITokenProvider.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Jugenddienst_Stunden.Interfaces;
|
||||
|
||||
internal interface ITokenProvider {
|
||||
string? GetToken();
|
||||
}
|
||||
Reference in New Issue
Block a user