diff --git a/FoodsharingSiegen.Server/App.razor b/FoodsharingSiegen.Server/App.razor
index 8bfd40b..4f02161 100644
--- a/FoodsharingSiegen.Server/App.razor
+++ b/FoodsharingSiegen.Server/App.razor
@@ -14,6 +14,7 @@
+
diff --git a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
index 66ff561..fec127f 100644
--- a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
+++ b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
@@ -37,6 +37,12 @@ namespace FoodsharingSiegen.Server.BaseClasses
[Inject]
protected IMessageService Message { get; set; } = null!;
+ ///
+ /// Gets or sets the modal service for handling modals within the application
+ ///
+ [Inject]
+ protected IModalService ModalService { get; set; } = null!;
+
///
/// Gets or sets the value of the navigation manager (ab)
///
diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor
index 98af0db..573bf09 100644
--- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor
+++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor
@@ -7,9 +7,9 @@
- @if (ProspectModal != null && CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
+ @if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
{
- ProspectModal.Show(Prospect)" @onclick:preventDefault>
+
}
@Prospect?.Name
@@ -28,7 +28,6 @@
}
-
? RemoveInteraction { get; set; }
[Parameter] public ProspectStateFilter StateFilter { get; set; }
@@ -26,7 +24,12 @@ namespace FoodsharingSiegen.Server.Controls
private List GetTyped(InteractionType type)
{
- return Prospect?.Interactions?.Where(x => x.Type == type).ToList() ?? new List();
+ return Prospect?.Interactions?.Where(x => x.Type == type).ToList() ?? [];
+ }
+
+ private async Task EditProspectAsync()
+ {
+ await EditProspectDialog.ShowAsync(ModalService, () => InvokeAsync(StateHasChanged), Prospect);
}
}
}
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Controls/ProspectGrid.razor b/FoodsharingSiegen.Server/Controls/ProspectGrid.razor
index 56b6edf..a588208 100644
--- a/FoodsharingSiegen.Server/Controls/ProspectGrid.razor
+++ b/FoodsharingSiegen.Server/Controls/ProspectGrid.razor
@@ -7,9 +7,7 @@
[Parameter] public Func? OnRemoveInteraction { get; set; }
[Parameter] public AddInteractionModal InteractionModal { get; set; } = null!;
-
- [Parameter] public AddProspectModal? ProspectModal { get; set; } = null!;
-
+
[Parameter] public ProspectStateFilter StateFilter { get; set; }
}
@@ -22,7 +20,6 @@
diff --git a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor
deleted file mode 100644
index 28c9d04..0000000
--- a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor
+++ /dev/null
@@ -1,38 +0,0 @@
-@using FoodsharingSiegen.Contracts.Entity
-
-
-
-
- @Header
-
-
-
-
-
-
- Name
-
-
-
-
-
- Foodsharing-ID
-
-
-
-
-
-
- Info (optional)
-
-
-
-
- Achtung!
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs
deleted file mode 100644
index 324ecca..0000000
--- a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using Blazorise;
-using FoodsharingSiegen.Contracts.Entity;
-using Microsoft.AspNetCore.Components;
-
-namespace FoodsharingSiegen.Server.Dialogs
-{
- ///
- /// The add prospect modal class (a. beging, 31.05.2022)
- ///
- public partial class AddProspectModal
- {
- #region Parameters
-
- ///
- /// Gets or sets the value of the on add (ab)
- ///
- [Parameter]
- public EventCallback OnAdd { get; set; }
-
- ///
- /// Gets or sets the value of the on update (ab)
- ///
- [Parameter]
- public EventCallback OnUpdate { get; set; }
-
- #endregion
-
- #region Private Properties
-
- ///
- /// Gets or sets the value of the header (ab)
- ///
- private string? Header { get; set; }
-
- ///
- /// Gets or sets the value of the is update mode (ab)
- ///
- private bool IsUpdateMode { get; set; }
-
- ///
- /// Gets or sets the value of the modal reference (ab)
- ///
- private Modal ModalReference { get; set; } = null!;
-
- ///
- /// Gets or sets the value of the prospect (ab)
- ///
- private Prospect Prospect { get; set; } = new();
-
- ///
- /// Gets or sets the value of the save button text (ab)
- ///
- private string? SaveButtonText { get; set; }
-
- #endregion
-
- #region Public Method Show
-
- ///
- /// Shows this instance (a. beging, 31.05.2022)
- ///
- public async Task Show()
- {
- Prospect = new Prospect();
- Header = "Neuling hinzufügen";
- SaveButtonText = "Hinzufügen";
- await ModalReference.Show();
- }
-
- ///
- /// Shows the prospect (a. beging, 31.05.2022)
- ///
- /// The prospect
- public async Task Show(Prospect? prospect)
- {
- if (prospect == null) return;
- Prospect = prospect;
- IsUpdateMode = true;
- Header = $"{Prospect.Name} bearbeiten";
- SaveButtonText = "Speichern";
- await ModalReference.Show();
- }
-
- #endregion
-
- #region Private Method SaveClick
-
- ///
- /// Saves the click (a. beging, 31.05.2022)
- ///
- private async Task SaveClick()
- {
- if (IsUpdateMode)
- await OnUpdate.InvokeAsync(Prospect);
- else
- await OnAdd.InvokeAsync(Prospect);
-
- await ModalReference.Hide();
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor
new file mode 100644
index 0000000..9c0aa3e
--- /dev/null
+++ b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor
@@ -0,0 +1,28 @@
+@using FoodsharingSiegen.Contracts.Entity
+@inherits FsBase
+
+
+
+
+ Name
+
+
+
+
+
+ Foodsharing-ID
+
+
+
+
+
+
+ Info (optional)
+
+
+
+
+ Achtung!
+
+
+
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor.cs b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor.cs
new file mode 100644
index 0000000..b175065
--- /dev/null
+++ b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor.cs
@@ -0,0 +1,106 @@
+using Blazorise;
+using FoodsharingSiegen.Contracts.Entity;
+using FoodsharingSiegen.Server.BaseClasses;
+using FoodsharingSiegen.Server.Data.Service;
+using Microsoft.AspNetCore.Components;
+
+namespace FoodsharingSiegen.Server.Dialogs
+{
+ ///
+ /// The add prospect modal class (a. beging, 31.05.2022)
+ ///
+ public partial class EditProspectDialog : FsBase
+ {
+ #region Dependencies
+
+ ///
+ /// Gets or sets the value of the prospect service (ab)
+ ///
+ [Inject]
+ public ProspectService ProspectService { get; set; } = null!;
+
+ #endregion
+
+ #region Parameters
+
+ ///
+ /// Gets or sets the value of the is update mode (ab)
+ ///
+ [Parameter]
+ public bool IsUpdateMode { get; set; }
+
+ [Parameter]
+ public Func? OnSuccess { get; set; }
+
+ ///
+ /// Gets or sets the value of the on add (ab)
+ ///
+ [Parameter]
+ public EventCallback OnAdd { get; set; }
+
+ ///
+ /// Gets or sets the value of the on update (ab)
+ ///
+ [Parameter]
+ public EventCallback OnUpdate { get; set; }
+
+ ///
+ /// Gets or sets the value of the prospect (ab)
+ ///
+ [Parameter]
+ public Prospect Prospect { get; set; } = new();
+
+ ///
+ /// Gets or sets the value of the save button text (ab)
+ ///
+ [Parameter]
+ public string? SaveButtonText { get; set; }
+
+ #endregion
+
+ #region Public Method ShowAsync
+
+ ///
+ /// Displays the AddProspectModal dialog asynchronously, allowing for the creation or editing of a prospect.
+ ///
+ /// The modal service used to display the dialog.
+ /// Callback to be invoked upon successful addition or update of a prospect.
+ /// The prospect to be edited, or null for creating a new prospect.
+ /// A task representing the asynchronous operation.
+ public static async Task ShowAsync(IModalService modalService, Func onSuccess, Prospect? prospect = null)
+ {
+ await modalService.Show(prospect == null ? "Neuling hinzufügen" : $"{prospect.Name} bearbeiten", p =>
+ {
+ p.Add(nameof(Prospect), prospect ?? new Prospect());
+ p.Add(nameof(IsUpdateMode), prospect != null);
+ p.Add(nameof(SaveButtonText), prospect == null ? "Hinzufügen" : "Speichern");
+ p.Add(nameof(OnSuccess), onSuccess);
+ });
+ }
+
+ #endregion
+
+ #region Private Method SaveClick
+
+ ///
+ /// Saves the click (a. beging, 31.05.2022)
+ ///
+ private async Task SaveClick()
+ {
+ if (IsUpdateMode)
+ {
+ var updateR = await ProspectService.UpdateAsync(Prospect);
+ if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
+ }
+ else
+ {
+ var addR = await ProspectService.AddProspectAsync(Prospect);
+ if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
+ }
+
+ await ModalService.Hide();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor
index 3dbaad0..cc5cae8 100644
--- a/FoodsharingSiegen.Server/Pages/Prospects.razor
+++ b/FoodsharingSiegen.Server/Pages/Prospects.razor
@@ -10,7 +10,7 @@
@@ -26,9 +26,7 @@
Prospects="filterList"
OnRemoveInteraction="RemoveInteractionAsync"
StateFilter="ProspectStateFilter.OnBoarding"
- InteractionModal="InteractionModal"
- ProspectModal="@ProspectModal">
+ InteractionModal="InteractionModal">
-
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs
index b231792..58c190e 100644
--- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs
+++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs
@@ -30,7 +30,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Properties
private ProspectFilter Filter { get; set; } = new();
-
+
///
/// Gets or sets the value of the interaction modal (ab)
///
@@ -41,11 +41,6 @@ namespace FoodsharingSiegen.Server.Pages
///
private List? ProspectList { get; set; }
- ///
- /// Gets or sets the value of the prospect modal (ab)
- ///
- private AddProspectModal ProspectModal { get; set; } = null!;
-
///
/// Gets or sets the value of the users (ab)
///
@@ -69,6 +64,19 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
+ #region Private Method CreateProspectAsync
+
+ ///
+ /// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list.
+ ///
+ /// A task that represents the asynchronous operation.
+ private async Task CreateProspectAsync()
+ {
+ await EditProspectDialog.ShowAsync(ModalService, LoadProspects);
+ }
+
+ #endregion
+
#region Private Method LoadProspects
///
@@ -80,7 +88,7 @@ namespace FoodsharingSiegen.Server.Pages
{
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
};
-
+
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
@@ -132,7 +140,7 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
- #region Private Method RemoveInteraction
+ #region Private Method RemoveInteractionAsync
///
/// Removes the interaction using the specified arg (a. beging, 11.04.2022)
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
index a913037..4dcfad5 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
+++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
@@ -3,8 +3,8 @@
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
-Abgeschlossene Einarbeitungen - @AppSettings.Terms.Title
-Abgeschlossene Einarbeitungen
+Abgeschlossen - @AppSettings.Terms.Title
+Abgeschlossen
@{
var filterList = ProspectList.ApplyFilter(Filter);
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
index deea75d..824fa11 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
+++ b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
@@ -19,10 +19,9 @@
{
}
-
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs
index b7f8b06..6fd4e56 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs
+++ b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs
@@ -40,9 +40,7 @@ namespace FoodsharingSiegen.Server.Pages
/// Gets or sets the value of the prospect list (ab)
///
private List? ProspectList { get; set; }
-
- private AddProspectModal? ProspectModal { get; set; }
-
+
///
/// Gets or sets the value of the users (ab)
///
diff --git a/FoodsharingSiegen.Server/config/appsettings.json b/FoodsharingSiegen.Server/config/appsettings.json
index 523efd3..bf6d20f 100644
--- a/FoodsharingSiegen.Server/config/appsettings.json
+++ b/FoodsharingSiegen.Server/config/appsettings.json
@@ -6,6 +6,7 @@
}
}
},
+ "DetailedErrors": true,
"Settings": {
"Terms": {
"Title": "Foodsharing Musterhausen",