Removing pointless WebsiteService.cs

This commit is contained in:
Jonathan
2025-06-22 22:46:45 -04:00
parent cf3f6e647b
commit 9e9b25ae6f
5 changed files with 3 additions and 103 deletions
+3 -7
View File
@@ -1,5 +1,6 @@
using Model.Entity.Data;
using Model.Website;
using Model.Website.Data;
namespace Services.Website;
@@ -7,14 +8,10 @@ public class SearchService : ISearchService
{
private readonly INoteService noteService;
private readonly IWebsiteService websiteService;
private bool isLoaded;
public SearchService(IWebsiteService websiteService, INoteService noteService)
public SearchService(INoteService noteService)
{
this.websiteService = websiteService;
this.noteService = noteService;
}
@@ -40,7 +37,6 @@ public class SearchService : ISearchService
public async Task Load()
{
await websiteService.Load();
await noteService.Load();
@@ -48,7 +44,7 @@ public class SearchService : ISearchService
Searches.Add("Notes", new List<SearchPointModel>());
Searches.Add("Entities", new List<SearchPointModel>());
foreach (var webPage in websiteService.WebPageModels)
foreach (var webPage in WebsiteData.GetPages())
{
SearchPoints.Add(new SearchPointModel
{
-76
View File
@@ -1,76 +0,0 @@
using System.Net.Http.Json;
using Model.Website;
namespace Services.Development;
public class WebsiteService : IWebsiteService
{
private readonly HttpClient httpClient;
private bool isLoaded;
public WebsiteService(HttpClient httpClient)
{
this.httpClient = httpClient;
}
public List<WebSectionModel> WebSectionModels { get; set; } = default!;
public List<WebPageModel> WebPageModels { get; set; } = default!;
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange -= action;
}
public bool IsLoaded()
{
return isLoaded;
}
public async Task Load()
{
if (isLoaded) return;
WebPageModels = (await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"))!.ToList();
WebSectionModels = (await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"))!
.ToList();
isLoaded = true;
SortSql();
NotifyDataChanged();
}
public void Update()
{
NotifyDataChanged();
}
private event Action OnChange = default!;
private void SortSql()
{
foreach (var page in WebPageModels)
if (page.WebSectionModelId != null)
{
var webSection =
WebSectionModels.Find(webSection => webSection.Id == page.WebSectionModelId);
webSection.WebPageModels.Add(page);
}
}
private void NotifyDataChanged()
{
OnChange?.Invoke();
}
}