diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor index 9d621ed..bf06d71 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor @@ -20,7 +20,15 @@ Profil öffnen -
@Prospect?.Memo
+ + @if (!string.IsNullOrWhiteSpace(Prospect?.Memo)) + { + + @Prospect?.Memo + + } + + OnAdd { get; set; } - - [Parameter] public EventCallback OnUpdate { get; set; } - - public async Task Show() - { - Prospect = new Prospect(); - Header = "Neuling hinzufügen"; - SaveButtonText = "Hinzufügen"; - await ModalReference.Show(); - } - - public async Task Show(Prospect? prospect) - { - if (prospect == null) return; - Prospect = prospect; - IsUpdateMode = true; - Header = $"{Prospect.Name} bearbeiten"; - SaveButtonText = "Speichern"; - await ModalReference.Show(); - } - - private async Task SaveClick() - { - if (IsUpdateMode) - await OnUpdate.InvokeAsync(Prospect); - else - await OnAdd.InvokeAsync(Prospect); - - await ModalReference.Hide(); - } -} - - + @Header - + +
+
+ + Name + + +
+
+ + Foodsharing-ID + + +
+
+ - Name - - - - Foodsharing-ID - + Memo (optional) +
diff --git a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs new file mode 100644 index 0000000..324ecca --- /dev/null +++ b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor.cs @@ -0,0 +1,103 @@ +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/Shared/NavMenu.razor b/FoodsharingSiegen.Server/Shared/NavMenu.razor index e26a1f0..a63e686 100644 --- a/FoodsharingSiegen.Server/Shared/NavMenu.razor +++ b/FoodsharingSiegen.Server/Shared/NavMenu.razor @@ -21,7 +21,7 @@ Übersicht -