diff --git a/IGP/PageLayout.razor b/IGP/PageLayout.razor index 8efc9f0..8e2cc77 100644 --- a/IGP/PageLayout.razor +++ b/IGP/PageLayout.razor @@ -1,6 +1,5 @@ @inherits LayoutComponentBase @inject ISearchService SearchService -@inject IWebsiteService WebService @inject IDataCollectionService DataCollectionService @inject NavigationManager NavigationManager @using Model.Website.Data @@ -79,7 +78,6 @@ protected override void OnInitialized() { base.OnInitialized(); - WebService.Subscribe(HasChanged); CollectFirstPageLoaded(); } @@ -110,8 +108,6 @@ protected override async Task OnInitializedAsync() { - await WebService.Load(); - await Focus(); } @@ -127,7 +123,6 @@ void IDisposable.Dispose() { - WebService.Unsubscribe(HasChanged); } void HasChanged() diff --git a/IGP/Program.cs b/IGP/Program.cs index 62bba37..ba5b518 100644 --- a/IGP/Program.cs +++ b/IGP/Program.cs @@ -57,7 +57,6 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/Services/IServices.cs b/Services/IServices.cs index 4441533..e7e74e0 100644 --- a/Services/IServices.cs +++ b/Services/IServices.cs @@ -121,20 +121,6 @@ public interface IEntityDialogService public bool HasHistory(); } -public interface IWebsiteService -{ - public List WebPageModels { get; set; } - public List WebSectionModels { get; set; } - - public void Subscribe(Action action); - public void Unsubscribe(Action action); - public void Update(); - - - public Task Load(); - - public bool IsLoaded(); -} public interface INoteService { diff --git a/Services/Website/SearchService.cs b/Services/Website/SearchService.cs index 7dbe916..3c47866 100644 --- a/Services/Website/SearchService.cs +++ b/Services/Website/SearchService.cs @@ -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()); Searches.Add("Entities", new List()); - foreach (var webPage in websiteService.WebPageModels) + foreach (var webPage in WebsiteData.GetPages()) { SearchPoints.Add(new SearchPointModel { diff --git a/Services/Website/WebsiteService.cs b/Services/Website/WebsiteService.cs deleted file mode 100644 index 16c050b..0000000 --- a/Services/Website/WebsiteService.cs +++ /dev/null @@ -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 WebSectionModels { get; set; } = default!; - public List 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("generated/WebPageModels.json"))!.ToList(); - WebSectionModels = (await httpClient.GetFromJsonAsync("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(); - } -} \ No newline at end of file