Refactor enums and update Interaction entity field

Moved enums to a dedicated namespace and updated references across the codebase. Renamed the `Info` field in the `Interaction` entity to `Info1`, including necessary migrations and UI adjustments. These changes improve the organization and consistency of the codebase.
This commit is contained in:
Andre Beging
2025-04-01 10:41:09 +02:00
parent 8595a18d0c
commit bf64239625
43 changed files with 509 additions and 231 deletions

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Contracts.Entity
{

View File

@@ -1,221 +0,0 @@
using FoodsharingSiegen.Contracts.Model;
namespace FoodsharingSiegen.Contracts.Entity
{
/// <summary>
/// The audit type enum
/// </summary>
public enum AuditType
{
/// <summary>
/// The none audit type
/// </summary>
None = 0,
// Profile
/// <summary>
/// The save profile audit type
/// </summary>
SaveProfile = 10,
#region Usermanagement
/// <summary>
/// The create user audit type
/// </summary>
CreateUser = 30,
/// <summary>
/// The update user audit type
/// </summary>
UpdateUser = 40,
/// <summary>
/// The remove user audit type
/// </summary>
RemoveUser = 50,
/// <summary>
/// The set user password audit type
/// </summary>
SetUserPassword = 60,
#endregion Usermanagement
#region Prospects
// Prospect
/// <summary>
/// The create prospect audit type
/// </summary>
CreateProspect = 70,
/// <summary>
/// The edit prospect audit type
/// </summary>
EditProspect = 80,
/// <summary>
/// The add interaction audit type
/// </summary>
AddInteraction = 90,
/// <summary>
/// The remove interaction audit type
/// </summary>
RemoveInteraction = 100
#endregion Prospects
}
/// <summary>
/// The user type enum
/// </summary>
public enum UserType
{
/// <summary>
/// The unverified user type
/// </summary>
Unverified = 100,
/// <summary>
/// The user user type
/// </summary>
User = 200,
/// <summary>
/// The admin user type
/// </summary>
Admin = 300
}
public enum ProspectStateFilter
{
All = 0,
OnBoarding = 10,
Verification = 20,
Completed = 30
}
/// <summary>
/// The user group enum
/// </summary>
public enum UserGroup
{
/// <summary>
/// The read only user group
/// </summary>
ReadOnly = 100,
/// <summary>
/// The welcome team user group
/// </summary>
WelcomeTeam = 200,
/// <summary>
/// The store manager user group
/// </summary>
StoreManager = 300,
/// <summary>
/// The ambassador user group
/// </summary>
Ambassador = 400
}
/// <summary>
/// Represents the state of a record within the system.
/// </summary>
public enum RecordState
{
Default = 10,
Deleted = 20
}
/// <summary>
/// The fs network type enum
/// </summary>
public enum FsNetworkType
{
/// <summary>
/// The germany fs network type
/// </summary>
[CustomValue("https://foodsharing.de")]
Germany = 0,
/// <summary>
/// The germany beta fs network type
/// </summary>
[CustomValue("https://beta.foodsharing.de")]
GermanyBeta = 10,
/// <summary>
/// The austria fs network type
/// </summary>
[CustomValue("https://foodsharing.at")]
Austria = 20,
/// <summary>
/// The austria beta fs network type
/// </summary>
[CustomValue("https://beta.foodsharing.at")]
AustriaBeta = 30,
/// <summary>
/// The switzerland fs network type
/// </summary>
[CustomValue("https://foodsharing.network")]
Switzerland = 40
}
/// <summary>
/// The interaction type enum
/// </summary>
public enum InteractionType
{
/// <summary>
/// The ein ab interaction type
/// </summary>
EinAb = 10,
/// <summary>
/// The welcome interaction type
/// </summary>
Welcome = 20,
/// <summary>
/// The id check interaction type
/// </summary>
IdCheck = 30,
/// <summary>
/// The print pass interaction type
/// </summary>
PrintPass = 40,
/// <summary>
/// The verify interaction type
/// </summary>
Verify = 60,
/// <summary>
/// The complete interaction type
/// </summary>
Complete = 70,
/// <summary>
/// The StepInBriefing interaction type
/// </summary>
StepInBriefing = 80,
/// <summary>
/// The StepInBriefing interaction type
/// </summary>
ReleasedForVerification = 90
}
}

View File

@@ -6,6 +6,7 @@ using System.Data;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Contracts.Entity
{
@@ -40,7 +41,7 @@ namespace FoodsharingSiegen.Contracts.Entity
/// <summary>
/// Gets or sets the value of the info (ab)
/// </summary>
public string? Info { get; set; }
public string? Info1 { get; set; }
/// <summary>
/// Gets or sets the value of the not needed (ab)

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Contracts.Entity
{

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Helper;
namespace FoodsharingSiegen.Contracts.Entity

View File

@@ -0,0 +1,69 @@
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// The audit type enum
/// </summary>
public enum AuditType
{
/// <summary>
/// The none audit type
/// </summary>
None = 0,
// Profile
/// <summary>
/// The save profile audit type
/// </summary>
SaveProfile = 10,
#region Usermanagement
/// <summary>
/// The create user audit type
/// </summary>
CreateUser = 30,
/// <summary>
/// The update user audit type
/// </summary>
UpdateUser = 40,
/// <summary>
/// The remove user audit type
/// </summary>
RemoveUser = 50,
/// <summary>
/// The set user password audit type
/// </summary>
SetUserPassword = 60,
#endregion Usermanagement
#region Prospects
// Prospect
/// <summary>
/// The create prospect audit type
/// </summary>
CreateProspect = 70,
/// <summary>
/// The edit prospect audit type
/// </summary>
EditProspect = 80,
/// <summary>
/// The add interaction audit type
/// </summary>
AddInteraction = 90,
/// <summary>
/// The remove interaction audit type
/// </summary>
RemoveInteraction = 100
#endregion Prospects
}
}

View File

@@ -0,0 +1,40 @@
using FoodsharingSiegen.Contracts.Model;
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// The fs network type enum
/// </summary>
public enum FsNetworkType
{
/// <summary>
/// The germany fs network type
/// </summary>
[CustomValue("https://foodsharing.de")]
Germany = 0,
/// <summary>
/// The germany beta fs network type
/// </summary>
[CustomValue("https://beta.foodsharing.de")]
GermanyBeta = 10,
/// <summary>
/// The austria fs network type
/// </summary>
[CustomValue("https://foodsharing.at")]
Austria = 20,
/// <summary>
/// The austria beta fs network type
/// </summary>
[CustomValue("https://beta.foodsharing.at")]
AustriaBeta = 30,
/// <summary>
/// The switzerland fs network type
/// </summary>
[CustomValue("https://foodsharing.network")]
Switzerland = 40
}
}

View File

@@ -0,0 +1,48 @@
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// The interaction type enum
/// </summary>
public enum InteractionType
{
/// <summary>
/// The ein ab interaction type
/// </summary>
EinAb = 10,
/// <summary>
/// The welcome interaction type
/// </summary>
Welcome = 20,
/// <summary>
/// The id check interaction type
/// </summary>
IdCheck = 30,
/// <summary>
/// The print pass interaction type
/// </summary>
PrintPass = 40,
/// <summary>
/// The verify interaction type
/// </summary>
Verify = 60,
/// <summary>
/// The complete interaction type
/// </summary>
Complete = 70,
/// <summary>
/// The StepInBriefing interaction type
/// </summary>
StepInBriefing = 80,
/// <summary>
/// The StepInBriefing interaction type
/// </summary>
ReleasedForVerification = 90
}
}

View File

@@ -0,0 +1,13 @@
namespace FoodsharingSiegen.Contracts.Enums
{
public enum ProspectStateFilter
{
All = 0,
OnBoarding = 10,
Verification = 20,
Completed = 30
}
}

View File

@@ -0,0 +1,12 @@
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// Represents the state of a record within the system.
/// </summary>
public enum RecordState
{
Default = 10,
Deleted = 20
}
}

View File

@@ -0,0 +1,28 @@
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// The user group enum
/// </summary>
public enum UserGroup
{
/// <summary>
/// The read only user group
/// </summary>
ReadOnly = 100,
/// <summary>
/// The welcome team user group
/// </summary>
WelcomeTeam = 200,
/// <summary>
/// The store manager user group
/// </summary>
StoreManager = 300,
/// <summary>
/// The ambassador user group
/// </summary>
Ambassador = 400
}
}

View File

@@ -0,0 +1,23 @@
namespace FoodsharingSiegen.Contracts.Enums
{
/// <summary>
/// The user type enum
/// </summary>
public enum UserType
{
/// <summary>
/// The unverified user type
/// </summary>
Unverified = 100,
/// <summary>
/// The user user type
/// </summary>
User = 200,
/// <summary>
/// The admin user type
/// </summary>
Admin = 300
}
}

View File

@@ -14,7 +14,7 @@ namespace FoodsharingSiegen.Contracts.Helper
/// </summary>
/// <param name="enumVal">The enum val</param>
/// <returns>The string</returns>
public static string GetCustomValue(this Enum enumVal)
public static string GetCustomValue(this System.Enum enumVal)
{
var attribute = enumVal.GetAttributeOfType<CustomValueAttribute>();
return attribute?.Value ?? string.Empty;
@@ -30,7 +30,7 @@ namespace FoodsharingSiegen.Contracts.Helper
/// <typeparam name="T">The </typeparam>
/// <param name="enumVal">The enum val</param>
/// <returns>The</returns>
private static T? GetAttributeOfType<T>(this Enum enumVal) where T : Attribute
private static T? GetAttributeOfType<T>(this System.Enum enumVal) where T : Attribute
{
var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString());

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Contracts.Helper
{

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Contracts.Model
{

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Helper;
using FoodsharingSiegen.Server.Data;
using FoodsharingSiegen.Server.Service;

View File

@@ -1,4 +1,5 @@
@using FoodsharingSiegen.Contracts.Entity
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@@ -30,9 +31,9 @@
}
</div>
@if (!string.IsNullOrWhiteSpace(interaction.Info))
@if (!string.IsNullOrWhiteSpace(interaction.Info1))
{
<span>(<i>@interaction.Info</i>)</span>
<span>(<i>@interaction.Info1</i>)</span>
}
</div>
}

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.BaseClasses;
using Microsoft.AspNetCore.Components;

View File

@@ -1,4 +1,5 @@
@using FoodsharingSiegen.Shared.Helper
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@{

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;
using FoodsharingSiegen.Shared.Helper;

View File

@@ -1,4 +1,5 @@
@using FoodsharingSiegen.Contracts.Model
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Contracts.Model
@inherits FsBase
@code {

View File

@@ -1,4 +1,5 @@
@code {
@using FoodsharingSiegen.Contracts.Enums
@code {
[Parameter] public List<Prospect>? Prospects { get; set; }

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
namespace FoodsharingSiegen.Server.Data
{

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.Auth;
using Microsoft.EntityFrameworkCore;

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Auth;
using Microsoft.EntityFrameworkCore;

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.Auth;
using Microsoft.EntityFrameworkCore;

View File

@@ -29,7 +29,7 @@
{
<Field>
<FieldLabel>@InfoName</FieldLabel>
<TextEdit @bind-Text="Interaction.Info"></TextEdit>
<TextEdit @bind-Text="Interaction.Info1"></TextEdit>
</Field>
}

View File

@@ -1,5 +1,6 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.BaseClasses;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;

View File

@@ -0,0 +1,208 @@
// <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("20250401075051_Rename-Info")]
partial class RenameInfo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
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>("Info1")
.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<DateTime?>("Modified")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("RecordState")
.HasColumnType("INTEGER");
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,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FoodsharingSiegen.Server.Migrations
{
/// <inheritdoc />
public partial class RenameInfo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Info",
table: "Interactions",
newName: "Info1");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Info1",
table: "Interactions",
newName: "Info");
}
}
}

View File

@@ -60,7 +60,7 @@ namespace FoodsharingSiegen.Server.Migrations
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Info")
b.Property<string>("Info1")
.HasColumnType("TEXT");
b.Property<bool>("NotNeeded")

View File

@@ -1,5 +1,6 @@
@page "/profile"
@using FoodsharingSiegen.Contracts.Enums
@inherits FsBase
<PageTitle>Profil - @AppSettings.Terms.Title</PageTitle>

View File

@@ -2,6 +2,7 @@
@page "/prospect"
@page "/prospects"
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;

View File

@@ -1,5 +1,6 @@
@page "/all"
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase

View File

@@ -1,5 +1,6 @@
@page "/done"
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;

View File

@@ -1,5 +1,6 @@
@page "/verify"
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;

View File

@@ -1,6 +1,7 @@
@page "/user"
@page "/users"
@using FoodsharingSiegen.Contracts.Entity
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Server.Dialogs
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase

View File

@@ -1,5 +1,6 @@
using Blazorise.DataGrid;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Helper;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;

View File

@@ -1,5 +1,6 @@
using System.Linq.Expressions;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
namespace FoodsharingSiegen.Shared.Helper

View File

@@ -1,6 +1,7 @@
#nullable enable
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
namespace FoodsharingSiegen.Shared.Helper