From 7c762e7d28ad44c70ff50a76a60dece87ad6f536 Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Sat, 11 Jun 2022 06:00:54 +0200 Subject: [PATCH] Allow Prospect Warnings --- .../Entity/Prospect.cs | 30 +-- .../Controls/ProspectContainer.razor | 9 +- .../Data/Service/ProspectService.cs | 1 + .../Dialogs/AddProspectModal.razor | 4 + .../20220611035052_User-Warning.Designer.cs | 201 ++++++++++++++++++ .../Migrations/20220611035052_User-Warning.cs | 26 +++ .../Migrations/FsContextModelSnapshot.cs | 3 + 7 files changed, 259 insertions(+), 15 deletions(-) create mode 100644 FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.Designer.cs create mode 100644 FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.cs diff --git a/FoodsharingSiegen.Contracts/Entity/Prospect.cs b/FoodsharingSiegen.Contracts/Entity/Prospect.cs index 8f42443..cf5632c 100644 --- a/FoodsharingSiegen.Contracts/Entity/Prospect.cs +++ b/FoodsharingSiegen.Contracts/Entity/Prospect.cs @@ -3,49 +3,55 @@ using System.ComponentModel.DataAnnotations.Schema; namespace FoodsharingSiegen.Contracts.Entity { - /// - /// The prospect class (a. beging, 21.05.2022) + /// The prospect class (a. beging, 21.05.2022) /// public class Prospect { #region Public Properties /// - /// Gets the value of the complete (ab) + /// Gets the value of the complete (ab) /// - [NotMapped] public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete); + [NotMapped] + public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete); /// - /// Gets or sets the value of the created (ab) + /// Gets or sets the value of the created (ab) /// public DateTime Created { get; set; } /// - /// Gets or sets the value of the fs id (ab) + /// Gets or sets the value of the fs id (ab) /// public int FsId { get; set; } /// - /// Gets or sets the value of the id (ab) + /// Gets or sets the value of the id (ab) /// - [Key] public Guid Id { get; set; } + [Key] + public Guid Id { get; set; } /// - /// Gets or sets the value of the interactions (ab) + /// Gets or sets the value of the interactions (ab) /// public IList Interactions { get; set; } /// - /// Gets or sets the value of the memo (ab) + /// Gets or sets the value of the memo (ab) /// public string? Memo { get; set; } /// - /// Gets or sets the value of the name (ab) + /// Gets or sets the value of the name (ab) /// public string Name { get; set; } + /// + /// Gets or sets the value of the warning (ab) + /// + public bool Warning { get; set; } + #endregion } -} +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor index bf06d71..d434e6c 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor @@ -21,10 +21,13 @@ - @if (!string.IsNullOrWhiteSpace(Prospect?.Memo)) + @if (!string.IsNullOrWhiteSpace(Prospect?.Memo) || Prospect?.Warning is true) { - - @Prospect?.Memo + var alertColor = Prospect?.Warning is true ? Color.Warning : Color.Info; + var alertIconClass = Prospect?.Warning is true ? "fa-solid fa-triangle-exclamation" : "fa-solid fa-circle-info"; + + + @Prospect?.Memo } diff --git a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs index cfbdb1f..910594f 100644 --- a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs +++ b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs @@ -161,6 +161,7 @@ namespace FoodsharingSiegen.Server.Data.Service entityProspect.Memo = prospect.Memo; entityProspect.Name = prospect.Name; entityProspect.FsId = prospect.FsId; + entityProspect.Warning = prospect.Warning; var saveR = await Context.SaveChangesAsync(); diff --git a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor index 1ccac42..dfa4a9c 100644 --- a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor +++ b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor @@ -26,6 +26,10 @@ Memo (optional) + + + Achtung! + diff --git a/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.Designer.cs b/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.Designer.cs new file mode 100644 index 0000000..576d002 --- /dev/null +++ b/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.Designer.cs @@ -0,0 +1,201 @@ +// +using System; +using FoodsharingSiegen.Server.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FoodsharingSiegen.Server.Migrations +{ + [DbContext(typeof(FsContext))] + [Migration("20220611035052_User-Warning")] + partial class UserWarning + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("Data1") + .HasColumnType("TEXT"); + + b.Property("Data2") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("UserID") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserID"); + + b.ToTable("Audits"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Alert") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Info") + .HasColumnType("TEXT"); + + b.Property("NotNeeded") + .HasColumnType("INTEGER"); + + b.Property("ProspectID") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("UserID") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ProspectID"); + + b.HasIndex("UserID"); + + b.ToTable("Interactions"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FsId") + .HasColumnType("INTEGER"); + + b.Property("Memo") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Warning") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Prospects"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("EncryptedPassword") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ForceLogout") + .HasColumnType("INTEGER"); + + b.Property("Groups") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Mail") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Memo") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Network") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Verified") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b => + { + b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User") + .WithMany() + .HasForeignKey("UserID"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b => + { + b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect") + .WithMany("Interactions") + .HasForeignKey("ProspectID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User") + .WithMany("Interactions") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Prospect"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b => + { + b.Navigation("Interactions"); + }); + + modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b => + { + b.Navigation("Interactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.cs b/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.cs new file mode 100644 index 0000000..8eed902 --- /dev/null +++ b/FoodsharingSiegen.Server/Migrations/20220611035052_User-Warning.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FoodsharingSiegen.Server.Migrations +{ + public partial class UserWarning : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Warning", + table: "Prospects", + type: "INTEGER", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Warning", + table: "Prospects"); + } + } +} diff --git a/FoodsharingSiegen.Server/Migrations/FsContextModelSnapshot.cs b/FoodsharingSiegen.Server/Migrations/FsContextModelSnapshot.cs index 297da56..6d661cc 100644 --- a/FoodsharingSiegen.Server/Migrations/FsContextModelSnapshot.cs +++ b/FoodsharingSiegen.Server/Migrations/FsContextModelSnapshot.cs @@ -103,6 +103,9 @@ namespace FoodsharingSiegen.Server.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("Warning") + .HasColumnType("INTEGER"); + b.HasKey("Id"); b.ToTable("Prospects");