diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
index d6b63a88..2074eb4e 100644
--- a/.github/workflows/sonarcloud.yml
+++ b/.github/workflows/sonarcloud.yml
@@ -14,7 +14,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 17
- distribution: 'zulu'
+ distribution: "zulu"
- uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -43,7 +43,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
- .\.sonar\scanner\dotnet-sonarscanner begin /k:"AnalogIO_analog-core" /o:"analogio" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="coverageunit.xml,coverageintegration.xml" /d:sonar.exclusions="CoffeeCard.Library/Migrations/*"
+ .\.sonar\scanner\dotnet-sonarscanner begin /k:"AnalogIO_analog-core" /o:"analogio" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="coverageunit.xml,coverageintegration.xml"
dotnet tool install --global coverlet.console
@@ -52,4 +52,5 @@ jobs:
coverlet ./coffeecard/CoffeeCard.Tests.Unit/bin/Debug/net8.0/CoffeeCard.Tests.Unit.dll --target "dotnet" --targetargs "test --no-build coffeecard/CoffeeCard.Tests.Unit" -f=opencover -o="coverageunit.xml"
coverlet ./coffeecard/CoffeeCard.Tests.Integration/bin/Debug/net8.0/CoffeeCard.Tests.Integration.dll --target "dotnet" --targetargs "test --no-build coffeecard/CoffeeCard.Tests.Integration" -f=opencover -o="coverageintegration.xml"
- .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
\ No newline at end of file
+ .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index c90c169a..78c51da9 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,5 +3,9 @@
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///c%3A/code/private/analogio/analog-core/.github/actions/deploy.yml",
"https://json.schemastore.org/github-action.json": "file:///c%3A/code/private/analogio/analog-core/.github/actions/core-sonarcloud.yml"
+ },
+ "sonarlint.connectedMode.project": {
+ "connectionId": "Analog",
+ "projectKey": "AnalogIO_analog-core"
}
}
\ No newline at end of file
diff --git a/coffeecard/CoffeeCard.Common/Configuration/EnvironmentSettings.cs b/coffeecard/CoffeeCard.Common/Configuration/EnvironmentSettings.cs
index 5741fdd2..dbb7115f 100644
--- a/coffeecard/CoffeeCard.Common/Configuration/EnvironmentSettings.cs
+++ b/coffeecard/CoffeeCard.Common/Configuration/EnvironmentSettings.cs
@@ -11,6 +11,8 @@ public class EnvironmentSettings : IValidatable
[Required] public string DeploymentUrl { get; set; }
+ [Required] public string ShiftyUrl { get; set; }
+
public void Validate()
{
Validator.ValidateObject(this, new ValidationContext(this), true);
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.Designer.cs b/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.Designer.cs
new file mode 100644
index 00000000..e6e5f7e1
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.Designer.cs
@@ -0,0 +1,663 @@
+//
+using System;
+using CoffeeCard.Library.Persistence;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ [DbContext(typeof(CoffeeCardContext))]
+ [Migration("20241022153731_AddTokenProperties")]
+ partial class AddTokenProperties
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("dbo")
+ .HasAnnotation("ProductVersion", "8.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Time")
+ .HasColumnType("datetime2");
+
+ b.Property("User_Id")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("User_Id");
+
+ b.ToTable("LoginAttempts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("MenuItems", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItemProduct", b =>
+ {
+ b.Property("MenuItemId")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.HasKey("MenuItemId", "ProductId");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("MenuItemProducts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("BaristaInitials")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("PurchaseId");
+
+ b.ToTable("PosPurchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExperienceWorth")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("Visible")
+ .HasColumnType("bit");
+
+ b.HasKey("Id");
+
+ b.ToTable("Products", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId", "UserGroup");
+
+ b.ToTable("ProductUserGroups", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ShortName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SortPriority")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Programmes", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalTransactionId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("OrderId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PurchasedById")
+ .HasColumnType("int")
+ .HasColumnName("PurchasedBy_Id");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ExternalTransactionId");
+
+ b.HasIndex("OrderId")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchasedById");
+
+ b.ToTable("Purchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime2");
+
+ b.Property("LastSwipe")
+ .HasColumnType("datetime2");
+
+ b.Property("Preset")
+ .HasColumnType("int");
+
+ b.Property("SwipeCount")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("Preset", "ExpiryDate");
+
+ b.ToTable("Statistics", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("IsUsed")
+ .HasColumnType("bit");
+
+ b.Property("OwnerId")
+ .HasColumnType("int")
+ .HasColumnName("Owner_Id");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int")
+ .HasColumnName("Purchase_Id");
+
+ b.Property("UsedOnMenuItemId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UsedOnMenuItemId");
+
+ b.ToTable("Tickets", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Expires")
+ .HasColumnType("datetime2");
+
+ b.Property("Revoked")
+ .HasColumnType("bit");
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Tokens", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Experience")
+ .HasColumnType("int");
+
+ b.Property("IsVerified")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PrivacyActivated")
+ .HasColumnType("bit");
+
+ b.Property("ProgrammeId")
+ .HasColumnType("int")
+ .HasColumnName("Programme_Id");
+
+ b.Property("Salt")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.Property("UserState")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Email");
+
+ b.HasIndex("Name");
+
+ b.HasIndex("ProgrammeId");
+
+ b.HasIndex("UserGroup");
+
+ b.ToTable("Users", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProductId")
+ .HasColumnType("int")
+ .HasColumnName("Product_Id");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("Requester")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Code")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Vouchers", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.WebhookConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("LastUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("SignatureKey")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WebhookConfigurations", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("LoginAttempts")
+ .HasForeignKey("User_Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItemProduct", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.MenuItem", "MenuItem")
+ .WithMany("MenuItemProducts")
+ .HasForeignKey("MenuItemId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany("MenuItemProducts")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("MenuItem");
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany("ProductUserGroup")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "PurchasedBy")
+ .WithMany("Purchases")
+ .HasForeignKey("PurchasedById")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+
+ b.Navigation("PurchasedBy");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Statistics")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "Owner")
+ .WithMany("Tickets")
+ .HasForeignKey("OwnerId")
+ .OnDelete(DeleteBehavior.NoAction)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany("Tickets")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.MenuItem", "UsedOnMenuItem")
+ .WithMany()
+ .HasForeignKey("UsedOnMenuItemId");
+
+ b.Navigation("Owner");
+
+ b.Navigation("Purchase");
+
+ b.Navigation("UsedOnMenuItem");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Tokens")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.NoAction);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Programme", "Programme")
+ .WithMany("Users")
+ .HasForeignKey("ProgrammeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Programme");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId");
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId");
+
+ b.Navigation("Product");
+
+ b.Navigation("Purchase");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItem", b =>
+ {
+ b.Navigation("MenuItemProducts");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Navigation("MenuItemProducts");
+
+ b.Navigation("ProductUserGroup");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Navigation("Users");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Navigation("Tickets");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Navigation("LoginAttempts");
+
+ b.Navigation("Purchases");
+
+ b.Navigation("Statistics");
+
+ b.Navigation("Tickets");
+
+ b.Navigation("Tokens");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.cs b/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.cs
new file mode 100644
index 00000000..86117337
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20241022153731_AddTokenProperties.cs
@@ -0,0 +1,58 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ ///
+ public partial class AddTokenProperties : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Expires",
+ schema: "dbo",
+ table: "Tokens",
+ type: "datetime2",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "Revoked",
+ schema: "dbo",
+ table: "Tokens",
+ type: "bit",
+ nullable: false,
+ defaultValue: false);
+
+ migrationBuilder.AddColumn(
+ name: "Type",
+ schema: "dbo",
+ table: "Tokens",
+ type: "nvarchar(max)",
+ nullable: false,
+ defaultValue: "");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Expires",
+ schema: "dbo",
+ table: "Tokens");
+
+ migrationBuilder.DropColumn(
+ name: "Revoked",
+ schema: "dbo",
+ table: "Tokens");
+
+ migrationBuilder.DropColumn(
+ name: "Type",
+ schema: "dbo",
+ table: "Tokens");
+ }
+ }
+}
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.Designer.cs b/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.Designer.cs
new file mode 100644
index 00000000..9507f06f
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.Designer.cs
@@ -0,0 +1,668 @@
+//
+using System;
+using CoffeeCard.Library.Persistence;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ [DbContext(typeof(CoffeeCardContext))]
+ [Migration("20241126213412_AddTokenHashIndex")]
+ partial class AddTokenHashIndex
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("dbo")
+ .HasAnnotation("ProductVersion", "8.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Time")
+ .HasColumnType("datetime2");
+
+ b.Property("User_Id")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("User_Id");
+
+ b.ToTable("LoginAttempts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("MenuItems", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItemProduct", b =>
+ {
+ b.Property("MenuItemId")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.HasKey("MenuItemId", "ProductId");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("MenuItemProducts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("BaristaInitials")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("PurchaseId");
+
+ b.ToTable("PosPurchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExperienceWorth")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("Visible")
+ .HasColumnType("bit");
+
+ b.HasKey("Id");
+
+ b.ToTable("Products", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId", "UserGroup");
+
+ b.ToTable("ProductUserGroups", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ShortName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SortPriority")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Programmes", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalTransactionId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("OrderId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PurchasedById")
+ .HasColumnType("int")
+ .HasColumnName("PurchasedBy_Id");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ExternalTransactionId");
+
+ b.HasIndex("OrderId")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchasedById");
+
+ b.ToTable("Purchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime2");
+
+ b.Property("LastSwipe")
+ .HasColumnType("datetime2");
+
+ b.Property("Preset")
+ .HasColumnType("int");
+
+ b.Property("SwipeCount")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("Preset", "ExpiryDate");
+
+ b.ToTable("Statistics", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("IsUsed")
+ .HasColumnType("bit");
+
+ b.Property("OwnerId")
+ .HasColumnType("int")
+ .HasColumnName("Owner_Id");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int")
+ .HasColumnName("Purchase_Id");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("UsedOnMenuItemId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UsedOnMenuItemId");
+
+ b.ToTable("Tickets", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Expires")
+ .HasColumnType("datetime2");
+
+ b.Property("Revoked")
+ .HasColumnType("bit");
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TokenHash");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Tokens", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Experience")
+ .HasColumnType("int");
+
+ b.Property("IsVerified")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PrivacyActivated")
+ .HasColumnType("bit");
+
+ b.Property("ProgrammeId")
+ .HasColumnType("int")
+ .HasColumnName("Programme_Id");
+
+ b.Property("Salt")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.Property("UserState")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Email");
+
+ b.HasIndex("Name");
+
+ b.HasIndex("ProgrammeId");
+
+ b.HasIndex("UserGroup");
+
+ b.ToTable("Users", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProductId")
+ .HasColumnType("int")
+ .HasColumnName("Product_Id");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("Requester")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Code")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Vouchers", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.WebhookConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("LastUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("SignatureKey")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WebhookConfigurations", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("LoginAttempts")
+ .HasForeignKey("User_Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItemProduct", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.MenuItem", "MenuItem")
+ .WithMany("MenuItemProducts")
+ .HasForeignKey("MenuItemId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany("MenuItemProducts")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("MenuItem");
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany("ProductUserGroup")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "PurchasedBy")
+ .WithMany("Purchases")
+ .HasForeignKey("PurchasedById")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+
+ b.Navigation("PurchasedBy");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Statistics")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "Owner")
+ .WithMany("Tickets")
+ .HasForeignKey("OwnerId")
+ .OnDelete(DeleteBehavior.NoAction)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany("Tickets")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.MenuItem", "UsedOnMenuItem")
+ .WithMany()
+ .HasForeignKey("UsedOnMenuItemId");
+
+ b.Navigation("Owner");
+
+ b.Navigation("Purchase");
+
+ b.Navigation("UsedOnMenuItem");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Tokens")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.NoAction);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Programme", "Programme")
+ .WithMany("Users")
+ .HasForeignKey("ProgrammeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Programme");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId");
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId");
+
+ b.Navigation("Product");
+
+ b.Navigation("Purchase");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItem", b =>
+ {
+ b.Navigation("MenuItemProducts");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Navigation("MenuItemProducts");
+
+ b.Navigation("ProductUserGroup");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Navigation("Users");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Navigation("Tickets");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Navigation("LoginAttempts");
+
+ b.Navigation("Purchases");
+
+ b.Navigation("Statistics");
+
+ b.Navigation("Tickets");
+
+ b.Navigation("Tokens");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.cs b/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.cs
new file mode 100644
index 00000000..eced786b
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20241126213412_AddTokenHashIndex.cs
@@ -0,0 +1,47 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ ///
+ public partial class AddTokenHashIndex : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "TokenHash",
+ schema: "dbo",
+ table: "Tokens",
+ type: "nvarchar(450)",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(max)");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Tokens_TokenHash",
+ schema: "dbo",
+ table: "Tokens",
+ column: "TokenHash");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_Tokens_TokenHash",
+ schema: "dbo",
+ table: "Tokens");
+
+ migrationBuilder.AlterColumn(
+ name: "TokenHash",
+ schema: "dbo",
+ table: "Tokens",
+ type: "nvarchar(max)",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(450)");
+ }
+ }
+}
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20241228184557_AddTokenExpiredFunction.Designer.cs b/coffeecard/CoffeeCard.Library/Migrations/20241228184557_AddTokenExpiredFunction.Designer.cs
new file mode 100644
index 00000000..720bd48d
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20241228184557_AddTokenExpiredFunction.Designer.cs
@@ -0,0 +1,668 @@
+//
+using System;
+using CoffeeCard.Library.Persistence;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ [DbContext(typeof(CoffeeCardContext))]
+ [Migration("20241228184557_AddTokenExpiredFunction")]
+ partial class AddTokenExpiredFunction
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("dbo")
+ .HasAnnotation("ProductVersion", "8.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Time")
+ .HasColumnType("datetime2");
+
+ b.Property("User_Id")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("User_Id");
+
+ b.ToTable("LoginAttempts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("MenuItems", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.MenuItemProduct", b =>
+ {
+ b.Property("MenuItemId")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.HasKey("MenuItemId", "ProductId");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("MenuItemProducts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("BaristaInitials")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("PurchaseId");
+
+ b.ToTable("PosPurchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExperienceWorth")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("Visible")
+ .HasColumnType("bit");
+
+ b.HasKey("Id");
+
+ b.ToTable("Products", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId", "UserGroup");
+
+ b.ToTable("ProductUserGroups", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ShortName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SortPriority")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Programmes", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalTransactionId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("OrderId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PurchasedById")
+ .HasColumnType("int")
+ .HasColumnName("PurchasedBy_Id");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ExternalTransactionId");
+
+ b.HasIndex("OrderId")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchasedById");
+
+ b.ToTable("Purchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime2");
+
+ b.Property("LastSwipe")
+ .HasColumnType("datetime2");
+
+ b.Property("Preset")
+ .HasColumnType("int");
+
+ b.Property("SwipeCount")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("Preset", "ExpiryDate");
+
+ b.ToTable("Statistics", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("IsUsed")
+ .HasColumnType("bit");
+
+ b.Property("OwnerId")
+ .HasColumnType("int")
+ .HasColumnName("Owner_Id");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int")
+ .HasColumnName("Purchase_Id");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("UsedOnMenuItemId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UsedOnMenuItemId");
+
+ b.ToTable("Tickets", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Expires")
+ .HasColumnType("datetime2");
+
+ b.Property("Revoked")
+ .HasColumnType("bit");
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TokenHash");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Tokens", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property