diff --git a/FoodsharingSiegen.Contracts/Model/Parameters.cs b/FoodsharingSiegen.Contracts/Model/Parameters.cs new file mode 100644 index 0000000..5e1181f --- /dev/null +++ b/FoodsharingSiegen.Contracts/Model/Parameters.cs @@ -0,0 +1,9 @@ +using FoodsharingSiegen.Contracts.Entity; + +namespace FoodsharingSiegen.Contracts.Model +{ + /// + /// The get prospects parameter + /// + public record GetProspectsParameter(List? MustHaveInteractions = null, List? CannotHaveInteractions = null); +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css index e6d15b3..e29ba55 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css @@ -18,7 +18,7 @@ flex-grow: 1; max-width: 480px; border: 1px solid #533a20; - border-radius: 15px; + border-radius: 7px; margin: 5px; padding: 16px; } diff --git a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs index 48cea9d..39893f8 100644 --- a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs +++ b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs @@ -1,5 +1,6 @@ using FoodsharingSiegen.Contracts; using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Server.Auth; using Microsoft.EntityFrameworkCore; @@ -103,12 +104,18 @@ namespace FoodsharingSiegen.Server.Data.Service /// Gets the users (a. beging, 01.04.2022) /// /// A task containing an operation result of list prospect - public async Task>> GetProspectsAsync(InteractionType? filterType = null) + public async Task>> GetProspectsAsync(GetProspectsParameter parameter) { try { var prospectsQuery = Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).AsQueryable(); - if(filterType != null) prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => i.Type == filterType)); + + if(parameter.MustHaveInteractions != null && parameter.MustHaveInteractions.Any()) + prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => parameter.MustHaveInteractions.Contains(i.Type))); + + if(parameter.CannotHaveInteractions != null && parameter.CannotHaveInteractions.Any()) + prospectsQuery = prospectsQuery.Where(x => x.Interactions.All(i => !parameter.CannotHaveInteractions.Contains(i.Type))); + var prospects = await prospectsQuery.ToListAsync(); return new OperationResult>(prospects); diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor index da6f7de..8d98bc9 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor @@ -1,16 +1,10 @@ @page "/" @page "/prospect" @page "/prospects" -@using FoodsharingSiegen.Server.Dialogs -@using FoodsharingSiegen.Server.Controls -@using FoodsharingSiegen.Contracts.Entity -@using FoodsharingSiegen.Contracts.Helper -@using FoodsharingSiegen.Server.BaseClasses @inherits FsBase -Einarbeitungen - +Aktuelle Einarbeitungen

Aktuelle Einarbeitungen

-@{ - var activeProspects = ProspectList?.Where(x => x.Interactions.All(i => i.Type != InteractionType.Complete)); -} -@if (activeProspects?.Any() == true) + +@if (ProspectList?.Any() == true) {
-

Aktuell:

+
@ProspectList.Count Einträge
- +
} - -@{ - var completedProspects = ProspectList?.Where(x => x.Interactions.Any(i => i.Type == InteractionType.Complete)); -} -@if (completedProspects?.Any() == true) -{ -
-

Abgeschlossen:

-
- - - -
-} - - \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs index ebd4571..c71e0f7 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs @@ -1,5 +1,6 @@ using Blazorise; using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Dialogs; using Microsoft.AspNetCore.Components; @@ -88,7 +89,11 @@ namespace FoodsharingSiegen.Server.Pages /// private async Task LoadProspects() { - var prospectsR = await ProspectService.GetProspectsAsync(); + var parameter = new GetProspectsParameter + { + CannotHaveInteractions = new List { InteractionType.Complete, InteractionType.Verify } + }; + var prospectsR = await ProspectService.GetProspectsAsync(parameter); if (prospectsR.Success) ProspectList = prospectsR.Data; await InvokeAsync(StateHasChanged); diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor new file mode 100644 index 0000000..4018d1e --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor @@ -0,0 +1,17 @@ +@page "/done" + +@inherits FsBase + +Abgeschlossene Einarbeitungen +

Abgeschlossene Einarbeitungen

+ +@if (ProspectList?.Any() == true) +{ +
+
@ProspectList.Count Einträge
+
+ + + +
+} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs new file mode 100644 index 0000000..1f1eb35 --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs @@ -0,0 +1,93 @@ +using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; +using FoodsharingSiegen.Server.Data.Service; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Pages +{ + /// + /// The prospects done class (a. beging, 07.02.2023) + /// + public partial class ProspectsTodo + { + #region Dependencies + + /// + /// Gets or sets the value of the prospect service (ab) + /// + [Inject] public ProspectService ProspectService { get; set; } = null!; + + #endregion + + #region Private Properties + + /// + /// Gets or sets the value of the prospect list (ab) + /// + private List? ProspectList { get; set; } + + #endregion + + #region Override OnAfterRenderAsync + + /// + /// Ons the after render using the specified first render (a. beging, 11.04.2022) + /// + /// The first render + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + await LoadProspects(); + + await base.OnAfterRenderAsync(firstRender); + } + + #endregion + + #region Private Method LoadProspects + + /// + /// Loads the prospects (a. beging, 11.04.2022) + /// + private async Task LoadProspects() + { + var parameter = new GetProspectsParameter + { + CannotHaveInteractions = new List { InteractionType.Complete }, + MustHaveInteractions = new List { InteractionType.Verify } + }; + var prospectsR = await ProspectService.GetProspectsAsync(parameter); + if (prospectsR.Success) ProspectList = prospectsR.Data; + + await InvokeAsync(StateHasChanged); + } + + #endregion + + #region Private Method RemoveInteraction + + /// + /// Removes the interaction using the specified arg (a. beging, 11.04.2022) + /// + /// The arg + private async Task RemoveInteraction(Guid arg) + { + var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => + { + o.ConfirmButtonText = "Ja, wirklich!"; + o.CancelButtonText = "Abbrechen"; + o.ShowMessageIcon = false; + }); + + if (confirm) + { + await ProspectService.RemoveInteraction(arg); + await LoadProspects(); + } + + await InvokeAsync(StateHasChanged); + } + + #endregion + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor new file mode 100644 index 0000000..5fa179a --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor @@ -0,0 +1,19 @@ +@page "/todo" + +@inherits FsBase + +Wartende Einarbeitungen + +

Wartende Einarbeitungen

+ +@if (ProspectList?.Any() == true) +{ +
+
@ProspectList.Count Einträge
+
Bereits verifiziert, aber noch nicht abgeschlossen. Zum Beispiel, wenn noch der Druck-Ausweis fehlt o.ä.
+
+ + + +
+} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs new file mode 100644 index 0000000..b1d3902 --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs @@ -0,0 +1,89 @@ +using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; +using FoodsharingSiegen.Server.Data.Service; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Pages +{ + /// + /// The prospects done class (a. beging, 07.02.2023) + /// + public partial class ProspectsDone + { + #region Dependencies + + /// + /// Gets or sets the value of the prospect service (ab) + /// + [Inject] public ProspectService ProspectService { get; set; } = null!; + + #endregion + + #region Private Properties + + /// + /// Gets or sets the value of the prospect list (ab) + /// + private List? ProspectList { get; set; } + + #endregion + + #region Override OnAfterRenderAsync + + /// + /// Ons the after render using the specified first render (a. beging, 11.04.2022) + /// + /// The first render + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + await LoadProspects(); + + await base.OnAfterRenderAsync(firstRender); + } + + #endregion + + #region Private Method LoadProspects + + /// + /// Loads the prospects (a. beging, 11.04.2022) + /// + private async Task LoadProspects() + { + var parameter = new GetProspectsParameter {MustHaveInteractions = new List { InteractionType.Complete }}; + var prospectsR = await ProspectService.GetProspectsAsync(parameter); + if (prospectsR.Success) ProspectList = prospectsR.Data; + + await InvokeAsync(StateHasChanged); + } + + #endregion + + #region Private Method RemoveInteraction + + /// + /// Removes the interaction using the specified arg (a. beging, 11.04.2022) + /// + /// The arg + private async Task RemoveInteraction(Guid arg) + { + var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => + { + o.ConfirmButtonText = "Ja, wirklich!"; + o.CancelButtonText = "Abbrechen"; + o.ShowMessageIcon = false; + }); + + if (confirm) + { + await ProspectService.RemoveInteraction(arg); + await LoadProspects(); + } + + await InvokeAsync(StateHasChanged); + } + + #endregion + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Shared/NavMenu.razor b/FoodsharingSiegen.Server/Shared/NavMenu.razor index a63e686..d2088db 100644 --- a/FoodsharingSiegen.Server/Shared/NavMenu.razor +++ b/FoodsharingSiegen.Server/Shared/NavMenu.razor @@ -1,4 +1,4 @@ -