Allow Prospect Warnings

This commit is contained in:
Andre Beging
2022-06-11 06:00:54 +02:00
parent 4a9fe8bed4
commit 7c762e7d28
7 changed files with 259 additions and 15 deletions

View File

@@ -3,49 +3,55 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace FoodsharingSiegen.Contracts.Entity namespace FoodsharingSiegen.Contracts.Entity
{ {
/// <summary> /// <summary>
/// The prospect class (a. beging, 21.05.2022) /// The prospect class (a. beging, 21.05.2022)
/// </summary> /// </summary>
public class Prospect public class Prospect
{ {
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// Gets the value of the complete (ab) /// Gets the value of the complete (ab)
/// </summary> /// </summary>
[NotMapped] public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete); [NotMapped]
public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete);
/// <summary> /// <summary>
/// Gets or sets the value of the created (ab) /// Gets or sets the value of the created (ab)
/// </summary> /// </summary>
public DateTime Created { get; set; } public DateTime Created { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the fs id (ab) /// Gets or sets the value of the fs id (ab)
/// </summary> /// </summary>
public int FsId { get; set; } public int FsId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the id (ab) /// Gets or sets the value of the id (ab)
/// </summary> /// </summary>
[Key] public Guid Id { get; set; } [Key]
public Guid Id { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the interactions (ab) /// Gets or sets the value of the interactions (ab)
/// </summary> /// </summary>
public IList<Interaction> Interactions { get; set; } public IList<Interaction> Interactions { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the memo (ab) /// Gets or sets the value of the memo (ab)
/// </summary> /// </summary>
public string? Memo { get; set; } public string? Memo { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the name (ab) /// Gets or sets the value of the name (ab)
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// Gets or sets the value of the warning (ab)
/// </summary>
public bool Warning { get; set; }
#endregion #endregion
} }
} }

View File

@@ -21,10 +21,13 @@
</small> </small>
</h5> </h5>
@if (!string.IsNullOrWhiteSpace(Prospect?.Memo)) @if (!string.IsNullOrWhiteSpace(Prospect?.Memo) || Prospect?.Warning is true)
{ {
<Alert Color="Color.Info" Visible Class="p-2 mb-1"> var alertColor = Prospect?.Warning is true ? Color.Warning : Color.Info;
<AlertDescription>@Prospect?.Memo</AlertDescription> var alertIconClass = Prospect?.Warning is true ? "fa-solid fa-triangle-exclamation" : "fa-solid fa-circle-info";
<Alert Color="alertColor" Visible Class="p-2 mb-1">
<AlertDescription><i class="@alertIconClass"></i> @Prospect?.Memo</AlertDescription>
</Alert> </Alert>
} }

View File

@@ -161,6 +161,7 @@ namespace FoodsharingSiegen.Server.Data.Service
entityProspect.Memo = prospect.Memo; entityProspect.Memo = prospect.Memo;
entityProspect.Name = prospect.Name; entityProspect.Name = prospect.Name;
entityProspect.FsId = prospect.FsId; entityProspect.FsId = prospect.FsId;
entityProspect.Warning = prospect.Warning;
var saveR = await Context.SaveChangesAsync(); var saveR = await Context.SaveChangesAsync();

View File

@@ -26,6 +26,10 @@
<FieldLabel>Memo (optional)</FieldLabel> <FieldLabel>Memo (optional)</FieldLabel>
<TextEdit @bind-Text="Prospect.Memo" Placeholder="Beliebige Info"></TextEdit> <TextEdit @bind-Text="Prospect.Memo" Placeholder="Beliebige Info"></TextEdit>
</Field> </Field>
<Field>
<Switch TValue="bool" @bind-Checked="Prospect.Warning">Achtung!</Switch>
</Field>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button Color="Color.Primary" Clicked="@SaveClick">@SaveButtonText</Button> <Button Color="Color.Primary" Clicked="@SaveClick">@SaveButtonText</Button>

View File

@@ -0,0 +1,201 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("Data1")
.HasColumnType("TEXT");
b.Property<string>("Data2")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.Property<Guid?>("UserID")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserID");
b.ToTable("Audits");
});
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<bool>("Alert")
.HasColumnType("INTEGER");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Info")
.HasColumnType("TEXT");
b.Property<bool>("NotNeeded")
.HasColumnType("INTEGER");
b.Property<Guid>("ProspectID")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.Property<Guid>("UserID")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ProspectID");
b.HasIndex("UserID");
b.ToTable("Interactions");
});
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<int>("FsId")
.HasColumnType("INTEGER");
b.Property<string>("Memo")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("Warning")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Prospects");
});
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("EncryptedPassword")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("ForceLogout")
.HasColumnType("INTEGER");
b.Property<string>("Groups")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Mail")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Memo")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Network")
.HasColumnType("INTEGER");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.Property<bool>("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
}
}
}

View File

@@ -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<bool>(
name: "Warning",
table: "Prospects",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Warning",
table: "Prospects");
}
}
}

View File

@@ -103,6 +103,9 @@ namespace FoodsharingSiegen.Server.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<bool>("Warning")
.HasColumnType("INTEGER");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Prospects"); b.ToTable("Prospects");