feat(Database) Adding entity dialog
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
#else
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
#endif
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Economy;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Entity.Data;
|
||||
using Model.Immortal.MemoryTester;
|
||||
using Model.Website;
|
||||
using Model.Website.Enums;
|
||||
@@ -14,6 +18,20 @@ using Services.Immortal;
|
||||
|
||||
namespace Services;
|
||||
|
||||
|
||||
public interface IEntityDialogService
|
||||
{
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
|
||||
public void AddDialog(string entityId);
|
||||
public void CloseDialog();
|
||||
|
||||
public string? GetEntityId();
|
||||
|
||||
public bool HasDialog();
|
||||
}
|
||||
|
||||
public interface IWebsiteService {
|
||||
#if NO_SQL
|
||||
public List<WebPageModel> WebPageModels { get; set; }
|
||||
|
||||
@@ -14,12 +14,12 @@ public enum EntityFilterEvent {
|
||||
public class EntityFilterService : IEntityFilterService {
|
||||
private readonly List<string> _entityChoices = new();
|
||||
|
||||
private readonly List<string> _factionChoices = new() { FactionType.QRath, FactionType.Aru, FactionType.Any };
|
||||
private readonly List<string> _factionChoices = new() { FactionType.Any, FactionType.QRath, FactionType.Aru };
|
||||
private readonly List<string> _immortalChoices = new();
|
||||
private string _entityType = EntityType.Army;
|
||||
private string _searchText = "";
|
||||
private string _selectedFaction = FactionType.QRath;
|
||||
private string _selectedImmortal = ImmortalType.Orzum;
|
||||
private string _selectedFaction = FactionType.Any;
|
||||
private string _selectedImmortal = ImmortalType.Any;
|
||||
|
||||
|
||||
public EntityFilterService() {
|
||||
@@ -118,7 +118,7 @@ public class EntityFilterService : IEntityFilterService {
|
||||
_immortalChoices.Clear();
|
||||
|
||||
//TODO Consider getting these values from the database
|
||||
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Any) {
|
||||
/*if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Any) {
|
||||
_immortalChoices.Add(ImmortalType.Orzum);
|
||||
_immortalChoices.Add(ImmortalType.Ajari);
|
||||
}
|
||||
@@ -126,6 +126,16 @@ public class EntityFilterService : IEntityFilterService {
|
||||
if (_selectedFaction == FactionType.Aru || _selectedFaction == FactionType.Any) {
|
||||
_immortalChoices.Add(ImmortalType.Mala);
|
||||
_immortalChoices.Add(ImmortalType.Xol);
|
||||
}*/
|
||||
|
||||
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Any) {
|
||||
_immortalChoices.Add(DataType.IMMORTAL_Orzum);
|
||||
_immortalChoices.Add(DataType.IMMORTAL_Ajari);
|
||||
}
|
||||
|
||||
if (_selectedFaction == FactionType.Aru || _selectedFaction == FactionType.Any) {
|
||||
_immortalChoices.Add(DataType.IMMORTAL_Mala);
|
||||
_immortalChoices.Add(DataType.IMMORTAL_Xol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Services.Website;
|
||||
|
||||
public class DialogService { }
|
||||
@@ -0,0 +1,49 @@
|
||||
using Model.Immortal.Entity;
|
||||
|
||||
namespace Services.Website;
|
||||
|
||||
public class EntityDialogService : IEntityDialogService
|
||||
{
|
||||
private string? entityId = null;
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange += action;
|
||||
}
|
||||
|
||||
public void AddDialog(string id)
|
||||
{
|
||||
entityId = id;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
entityId = null;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
|
||||
public bool HasDialog()
|
||||
{
|
||||
return entityId != null;
|
||||
}
|
||||
|
||||
public string? GetEntityId()
|
||||
{
|
||||
return entityId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using System.Net.Http.Json;
|
||||
|
||||
#if !NO_SQL
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
#endif
|
||||
|
||||
using Model.Website;
|
||||
|
||||
namespace Services.Work;
|
||||
@@ -10,6 +14,10 @@ public class WebsiteService : IWebsiteService {
|
||||
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
|
||||
public WebsiteService(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
@@ -76,8 +84,6 @@ public class WebsiteService : IWebsiteService {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user