diff --git a/Aberwyn/Controllers/FoodMenuController.cs b/Aberwyn/Controllers/FoodMenuController.cs index 0e37d8a..0fa5171 100644 --- a/Aberwyn/Controllers/FoodMenuController.cs +++ b/Aberwyn/Controllers/FoodMenuController.cs @@ -10,6 +10,8 @@ using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using Aberwyn.Services; namespace Aberwyn.Controllers { @@ -19,14 +21,18 @@ namespace Aberwyn.Controllers private readonly IHostEnvironment _env; private readonly MenuService _menuService; private readonly ApplicationDbContext _context; + private readonly PushNotificationService _notificationService; + private readonly PizzaNotificationService _pizzaNotifier; - public FoodMenuController(MenuService menuService, IConfiguration configuration, IHostEnvironment env, ApplicationDbContext context) + public FoodMenuController(MenuService menuService, IConfiguration configuration, IHostEnvironment env, ApplicationDbContext context, PushNotificationService notificationService, PizzaNotificationService pizzaNotificationService) { _menuService = menuService; - + _configuration = configuration; _env = env; _context = context; + _notificationService = notificationService; + _pizzaNotifier = pizzaNotificationService; } [HttpGet] @@ -83,11 +89,11 @@ namespace Aberwyn.Controllers [HttpPost] - public IActionResult PizzaOrder(string customerName, string pizzaName, string ingredients, int? orderId) + public async Task PizzaOrder(string customerName, string pizzaName, string ingredients, int? orderId) { if (string.IsNullOrWhiteSpace(customerName) || string.IsNullOrWhiteSpace(pizzaName)) { - TempData["Error"] = "Fyll i b�de namn och pizza!"; + TempData["Error"] = "Fyll i både namn och pizza!"; return RedirectToAction("PizzaOrder"); } @@ -103,10 +109,10 @@ namespace Aberwyn.Controllers order.CustomerName = customerName.Trim(); order.PizzaName = pizzaName.Trim(); order.IngredientsJson = ingredients; - order.Status = "Unconfirmed";// �terst�ll status om du vill + order.Status = "Unconfirmed"; _context.SaveChanges(); - TempData["Success"] = $"Din best�llning har uppdaterats!"; + TempData["Success"] = $"Din beställning har uppdaterats!"; return RedirectToAction("PizzaOrder"); } } @@ -124,11 +130,11 @@ namespace Aberwyn.Controllers _context.PizzaOrders.Add(order); _context.SaveChanges(); TempData["ForceShowForm"] = "true"; - + await _pizzaNotifier.NotifyPizzaSubscribersAsync(order.PizzaName, order.CustomerName); HttpContext.Session.SetInt32("LastPizzaOrderId", order.Id); - TempData["Success"] = $"Tack {order.CustomerName}! Din pizza �r best�lld!"; + TempData["Success"] = $"Tack {order.CustomerName}! Din pizza är beställd!"; return RedirectToAction("PizzaOrder"); } @@ -172,19 +178,42 @@ namespace Aberwyn.Controllers [HttpPost] [Authorize(Roles = "Chef")] - public IActionResult UpdatePizzaOrder(int id, string status, string ingredientsJson) + public async Task UpdatePizzaOrder(int id, string status, string ingredientsJson) { - var order = _context.PizzaOrders.FirstOrDefault(p => p.Id == id); - if (order != null) + var order = await _context.PizzaOrders.FirstOrDefaultAsync(p => p.Id == id); + if (order == null) + return RedirectToAction("PizzaAdmin"); + + order.Status = status; + order.IngredientsJson = ingredientsJson; + await _context.SaveChangesAsync(); + + // Skicka pushnotiser till kopplade prenumeranter + var subscribers = await _context.PushSubscribers + .Where(s => s.PizzaOrderId == id) + .ToListAsync(); + + var payload = $@"{{ + ""title"": ""Din pizza! 🍕"", + ""body"": ""Statusuppdatering: {status}"" + }}"; + + foreach (var sub in subscribers) { - order.Status = status; - order.IngredientsJson = ingredientsJson; - _context.SaveChanges(); + try + { + _notificationService.SendNotification(sub.Endpoint, sub.P256DH, sub.Auth, payload); + } + catch (Exception ex) + { + Console.WriteLine($"❌ Kunde inte skicka notis till {sub.Endpoint}: {ex.Message}"); + } } return RedirectToAction("PizzaAdmin"); } + [Authorize(Roles = "Chef")] public IActionResult Veckomeny(int? week, int? year) { diff --git a/Aberwyn/Controllers/PushController.cs b/Aberwyn/Controllers/PushController.cs index 4dd98dc..9fecf03 100644 --- a/Aberwyn/Controllers/PushController.cs +++ b/Aberwyn/Controllers/PushController.cs @@ -40,35 +40,40 @@ namespace Aberwyn.Controllers [HttpPost("subscribe")] - public async Task Subscribe([FromBody] PushSubscription subscription) + public async Task Subscribe([FromBody] PushSubscriptionWithOrder dto) { var existing = await _context.PushSubscribers - .FirstOrDefaultAsync(s => s.Endpoint == subscription.Endpoint); - var user = await _userManager.GetUserAsync(User); - if (user == null) return Unauthorized(); + .FirstOrDefaultAsync(s => s.Endpoint == dto.Subscription.Endpoint); if (existing == null) { - var newSubscriber = new PushSubscriber + var newSub = new PushSubscriber { - Endpoint = subscription.Endpoint, - P256DH = subscription.Keys["p256dh"], - Auth = subscription.Keys["auth"], - UserId = user.Id + Endpoint = dto.Subscription.Endpoint, + P256DH = dto.Subscription.Keys["p256dh"], + Auth = dto.Subscription.Keys["auth"], + PizzaOrderId = dto.PizzaOrderId }; - - _context.PushSubscribers.Add(newSubscriber); + _context.PushSubscribers.Add(newSub); } else { - existing.P256DH = subscription.Keys["p256dh"]; - existing.Auth = subscription.Keys["auth"]; + existing.P256DH = dto.Subscription.Keys["p256dh"]; + existing.Auth = dto.Subscription.Keys["auth"]; + existing.PizzaOrderId = dto.PizzaOrderId; // uppdatera kopplingen } - await _context.SaveChangesAsync(); + await _context.SaveChangesAsync(); return Ok(); } + public class PushSubscriptionWithOrder + { + public PushSubscription Subscription { get; set; } + public int PizzaOrderId { get; set; } + } + + [HttpGet("vapid-public-key")] public IActionResult GetVapidKey([FromServices] IConfiguration config) { @@ -109,6 +114,24 @@ namespace Aberwyn.Controllers return Ok($"Skickade notiser till {successCount} användare."); } + [HttpPost("unsubscribe")] + public async Task Unsubscribe([FromBody] PushUnsubscribeDto dto) + { + var sub = await _context.PushSubscribers.FirstOrDefaultAsync(s => s.Endpoint == dto.Endpoint); + if (sub != null) + { + _context.PushSubscribers.Remove(sub); + await _context.SaveChangesAsync(); + } + return Ok(); + } + + public class PushUnsubscribeDto + { + public string Endpoint { get; set; } + } + + } } diff --git a/Aberwyn/Data/PizzaNotificationService.cs b/Aberwyn/Data/PizzaNotificationService.cs index 81d42a6..8a3363b 100644 --- a/Aberwyn/Data/PizzaNotificationService.cs +++ b/Aberwyn/Data/PizzaNotificationService.cs @@ -40,8 +40,15 @@ namespace Aberwyn.Services s.Endpoint.StartsWith("https://")) .ToListAsync(); - - int successCount = 0; + var allSubscribers = await _context.PushSubscribers + .Include(s => s.User) + .ThenInclude(u => u.Preferences) + .ToListAsync(); + foreach (var s in allSubscribers) + { + Console.WriteLine($"🔍 Sub: {s.Endpoint}, User: {s.User?.UserName}, NotifyPizza: {s.User?.Preferences?.NotifyPizza}"); + } + int successCount = 0; foreach (var sub in subscribers) { try diff --git a/Aberwyn/Migrations/20250604220420_AssignedToNullable.Designer.cs b/Aberwyn/Migrations/20250604220420_AssignedToNullable.Designer.cs deleted file mode 100644 index 5a8c695..0000000 --- a/Aberwyn/Migrations/20250604220420_AssignedToNullable.Designer.cs +++ /dev/null @@ -1,676 +0,0 @@ -// -using System; -using Aberwyn.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Aberwyn.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250604220420_AssignedToNullable")] - partial class AssignedToNullable - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.36") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.AppSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AppSettings"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BudgetCategoryDefinitionId") - .HasColumnType("int"); - - b.Property("BudgetPeriodId") - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryDefinitionId"); - - b.HasIndex("BudgetPeriodId"); - - b.ToTable("BudgetCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategoryDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetCategoryDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("decimal(65,30)"); - - b.Property("BudgetCategoryId") - .HasColumnType("int"); - - b.Property("BudgetItemDefinitionId") - .HasColumnType("int"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryId"); - - b.HasIndex("BudgetItemDefinitionId"); - - b.ToTable("BudgetItems"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItemDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultCategory") - .HasColumnType("longtext"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetItemDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Month") - .HasColumnType("int"); - - b.Property("Order") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("BudgetPeriods"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Item") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MealId") - .HasColumnType("int"); - - b.Property("Quantity") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("MealId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CarbType") - .HasColumnType("longtext"); - - b.Property("Category") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("ImageData") - .HasColumnType("longblob"); - - b.Property("ImageMimeType") - .HasColumnType("longtext"); - - b.Property("ImageUrl") - .HasColumnType("longtext"); - - b.Property("Instructions") - .HasColumnType("longtext"); - - b.Property("IsAvailable") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProteinType") - .HasColumnType("longtext"); - - b.Property("RecipeUrl") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Meals"); - }); - - modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CustomerName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IngredientsJson") - .HasColumnType("longtext"); - - b.Property("OrderedAt") - .HasColumnType("datetime(6)"); - - b.Property("PizzaName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PizzaOrders"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PushSubscribers"); - }); - - modelBuilder.Entity("Aberwyn.Models.TodoTask", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedTo") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Tags") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("TodoTasks"); - }); - - modelBuilder.Entity("Aberwyn.Models.WeeklyMenu", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BreakfastMealId") - .HasColumnType("int"); - - b.Property("Cook") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DayOfWeek") - .HasColumnType("int"); - - b.Property("DinnerMealId") - .HasColumnType("int"); - - b.Property("LunchMealId") - .HasColumnType("int"); - - b.Property("WeekNumber") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WeeklyMenu", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.HasOne("Aberwyn.Models.BudgetCategoryDefinition", "Definition") - .WithMany() - .HasForeignKey("BudgetCategoryDefinitionId"); - - b.HasOne("Aberwyn.Models.BudgetPeriod", "BudgetPeriod") - .WithMany("Categories") - .HasForeignKey("BudgetPeriodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BudgetPeriod"); - - b.Navigation("Definition"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.HasOne("Aberwyn.Models.BudgetCategory", "BudgetCategory") - .WithMany("Items") - .HasForeignKey("BudgetCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.BudgetItemDefinition", "BudgetItemDefinition") - .WithMany() - .HasForeignKey("BudgetItemDefinitionId"); - - b.Navigation("BudgetCategory"); - - b.Navigation("BudgetItemDefinition"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.HasOne("Aberwyn.Models.Meal", null) - .WithMany("Ingredients") - .HasForeignKey("MealId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Navigation("Items"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Navigation("Categories"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Navigation("Ingredients"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Aberwyn/Migrations/20250604220420_AssignedToNullable.cs b/Aberwyn/Migrations/20250604220420_AssignedToNullable.cs deleted file mode 100644 index 66c5ae2..0000000 --- a/Aberwyn/Migrations/20250604220420_AssignedToNullable.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Aberwyn.Migrations -{ - public partial class AssignedToNullable : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "AssignedTo", - table: "TodoTasks", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "TodoTasks", - keyColumn: "AssignedTo", - keyValue: null, - column: "AssignedTo", - value: ""); - - migrationBuilder.AlterColumn( - name: "AssignedTo", - table: "TodoTasks", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.Designer.cs b/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.Designer.cs deleted file mode 100644 index ad83b7c..0000000 --- a/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.Designer.cs +++ /dev/null @@ -1,679 +0,0 @@ -// -using System; -using Aberwyn.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Aberwyn.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250605062804_AddThumbnailToMeal")] - partial class AddThumbnailToMeal - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.36") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.AppSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AppSettings"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BudgetCategoryDefinitionId") - .HasColumnType("int"); - - b.Property("BudgetPeriodId") - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryDefinitionId"); - - b.HasIndex("BudgetPeriodId"); - - b.ToTable("BudgetCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategoryDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetCategoryDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("decimal(65,30)"); - - b.Property("BudgetCategoryId") - .HasColumnType("int"); - - b.Property("BudgetItemDefinitionId") - .HasColumnType("int"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryId"); - - b.HasIndex("BudgetItemDefinitionId"); - - b.ToTable("BudgetItems"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItemDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultCategory") - .HasColumnType("longtext"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetItemDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Month") - .HasColumnType("int"); - - b.Property("Order") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("BudgetPeriods"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Item") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MealId") - .HasColumnType("int"); - - b.Property("Quantity") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("MealId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CarbType") - .HasColumnType("longtext"); - - b.Property("Category") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("ImageData") - .HasColumnType("longblob"); - - b.Property("ImageMimeType") - .HasColumnType("longtext"); - - b.Property("ImageUrl") - .HasColumnType("longtext"); - - b.Property("Instructions") - .HasColumnType("longtext"); - - b.Property("IsAvailable") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProteinType") - .HasColumnType("longtext"); - - b.Property("RecipeUrl") - .HasColumnType("longtext"); - - b.Property("ThumbnailData") - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("Meals"); - }); - - modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CustomerName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IngredientsJson") - .HasColumnType("longtext"); - - b.Property("OrderedAt") - .HasColumnType("datetime(6)"); - - b.Property("PizzaName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PizzaOrders"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PushSubscribers"); - }); - - modelBuilder.Entity("Aberwyn.Models.TodoTask", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedTo") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Tags") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("TodoTasks"); - }); - - modelBuilder.Entity("Aberwyn.Models.WeeklyMenu", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BreakfastMealId") - .HasColumnType("int"); - - b.Property("Cook") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DayOfWeek") - .HasColumnType("int"); - - b.Property("DinnerMealId") - .HasColumnType("int"); - - b.Property("LunchMealId") - .HasColumnType("int"); - - b.Property("WeekNumber") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WeeklyMenu", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.HasOne("Aberwyn.Models.BudgetCategoryDefinition", "Definition") - .WithMany() - .HasForeignKey("BudgetCategoryDefinitionId"); - - b.HasOne("Aberwyn.Models.BudgetPeriod", "BudgetPeriod") - .WithMany("Categories") - .HasForeignKey("BudgetPeriodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BudgetPeriod"); - - b.Navigation("Definition"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.HasOne("Aberwyn.Models.BudgetCategory", "BudgetCategory") - .WithMany("Items") - .HasForeignKey("BudgetCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.BudgetItemDefinition", "BudgetItemDefinition") - .WithMany() - .HasForeignKey("BudgetItemDefinitionId"); - - b.Navigation("BudgetCategory"); - - b.Navigation("BudgetItemDefinition"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.HasOne("Aberwyn.Models.Meal", null) - .WithMany("Ingredients") - .HasForeignKey("MealId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Navigation("Items"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Navigation("Categories"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Navigation("Ingredients"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.cs b/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.cs deleted file mode 100644 index 7b078cf..0000000 --- a/Aberwyn/Migrations/20250605062804_AddThumbnailToMeal.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Aberwyn.Migrations -{ - public partial class AddThumbnailToMeal : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ThumbnailData", - table: "Meals", - type: "longblob", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ThumbnailData", - table: "Meals"); - } - } -} diff --git a/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.Designer.cs b/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.Designer.cs deleted file mode 100644 index 40f1680..0000000 --- a/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.Designer.cs +++ /dev/null @@ -1,755 +0,0 @@ -// -using System; -using Aberwyn.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Aberwyn.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250606061016_AddUserPreferencesAndPushSubscriptions")] - partial class AddUserPreferencesAndPushSubscriptions - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.36") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.AppSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AppSettings"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BudgetCategoryDefinitionId") - .HasColumnType("int"); - - b.Property("BudgetPeriodId") - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryDefinitionId"); - - b.HasIndex("BudgetPeriodId"); - - b.ToTable("BudgetCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategoryDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetCategoryDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("decimal(65,30)"); - - b.Property("BudgetCategoryId") - .HasColumnType("int"); - - b.Property("BudgetItemDefinitionId") - .HasColumnType("int"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryId"); - - b.HasIndex("BudgetItemDefinitionId"); - - b.ToTable("BudgetItems"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItemDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultCategory") - .HasColumnType("longtext"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetItemDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Month") - .HasColumnType("int"); - - b.Property("Order") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("BudgetPeriods"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Item") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MealId") - .HasColumnType("int"); - - b.Property("Quantity") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("MealId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CarbType") - .HasColumnType("longtext"); - - b.Property("Category") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("ImageData") - .HasColumnType("longblob"); - - b.Property("ImageMimeType") - .HasColumnType("longtext"); - - b.Property("ImageUrl") - .HasColumnType("longtext"); - - b.Property("Instructions") - .HasColumnType("longtext"); - - b.Property("IsAvailable") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProteinType") - .HasColumnType("longtext"); - - b.Property("RecipeUrl") - .HasColumnType("longtext"); - - b.Property("ThumbnailData") - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("Meals"); - }); - - modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CustomerName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IngredientsJson") - .HasColumnType("longtext"); - - b.Property("OrderedAt") - .HasColumnType("datetime(6)"); - - b.Property("PizzaName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PizzaOrders"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PushSubscribers"); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("PushSubscriptions"); - }); - - modelBuilder.Entity("Aberwyn.Models.TodoTask", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedTo") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Tags") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("TodoTasks"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("NotifyBudget") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyMenu") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyPizza") - .HasColumnType("tinyint(1)"); - - b.HasKey("UserId"); - - b.ToTable("UserPreferences"); - }); - - modelBuilder.Entity("Aberwyn.Models.WeeklyMenu", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BreakfastMealId") - .HasColumnType("int"); - - b.Property("Cook") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DayOfWeek") - .HasColumnType("int"); - - b.Property("DinnerMealId") - .HasColumnType("int"); - - b.Property("LunchMealId") - .HasColumnType("int"); - - b.Property("WeekNumber") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WeeklyMenu", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.HasOne("Aberwyn.Models.BudgetCategoryDefinition", "Definition") - .WithMany() - .HasForeignKey("BudgetCategoryDefinitionId"); - - b.HasOne("Aberwyn.Models.BudgetPeriod", "BudgetPeriod") - .WithMany("Categories") - .HasForeignKey("BudgetPeriodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BudgetPeriod"); - - b.Navigation("Definition"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.HasOne("Aberwyn.Models.BudgetCategory", "BudgetCategory") - .WithMany("Items") - .HasForeignKey("BudgetCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.BudgetItemDefinition", "BudgetItemDefinition") - .WithMany() - .HasForeignKey("BudgetItemDefinitionId"); - - b.Navigation("BudgetCategory"); - - b.Navigation("BudgetItemDefinition"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.HasOne("Aberwyn.Models.Meal", null) - .WithMany("Ingredients") - .HasForeignKey("MealId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithOne("Preferences") - .HasForeignKey("Aberwyn.Models.UserPreferences", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Navigation("Preferences") - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Navigation("Items"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Navigation("Categories"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Navigation("Ingredients"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.cs b/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.cs deleted file mode 100644 index 722ec26..0000000 --- a/Aberwyn/Migrations/20250606061016_AddUserPreferencesAndPushSubscriptions.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Aberwyn.Migrations -{ - public partial class AddUserPreferencesAndPushSubscriptions : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "PushSubscriptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Endpoint = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - P256DH = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Auth = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_PushSubscriptions", x => x.Id); - table.ForeignKey( - name: "FK_PushSubscriptions_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "UserPreferences", - columns: table => new - { - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - NotifyPizza = table.Column(type: "tinyint(1)", nullable: false), - NotifyMenu = table.Column(type: "tinyint(1)", nullable: false), - NotifyBudget = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserPreferences", x => x.UserId); - table.ForeignKey( - name: "FK_UserPreferences_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_PushSubscriptions_UserId", - table: "PushSubscriptions", - column: "UserId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PushSubscriptions"); - - migrationBuilder.DropTable( - name: "UserPreferences"); - } - } -} diff --git a/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.Designer.cs b/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.Designer.cs deleted file mode 100644 index 9906330..0000000 --- a/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.Designer.cs +++ /dev/null @@ -1,772 +0,0 @@ -// -using System; -using Aberwyn.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Aberwyn.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250606100439_AddPushSubscriberUserLink")] - partial class AddPushSubscriberUserLink - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.36") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.AppSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AppSettings"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BudgetCategoryDefinitionId") - .HasColumnType("int"); - - b.Property("BudgetPeriodId") - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryDefinitionId"); - - b.HasIndex("BudgetPeriodId"); - - b.ToTable("BudgetCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategoryDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetCategoryDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("decimal(65,30)"); - - b.Property("BudgetCategoryId") - .HasColumnType("int"); - - b.Property("BudgetItemDefinitionId") - .HasColumnType("int"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryId"); - - b.HasIndex("BudgetItemDefinitionId"); - - b.ToTable("BudgetItems"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItemDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultCategory") - .HasColumnType("longtext"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetItemDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Month") - .HasColumnType("int"); - - b.Property("Order") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("BudgetPeriods"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Item") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MealId") - .HasColumnType("int"); - - b.Property("Quantity") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("MealId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CarbType") - .HasColumnType("longtext"); - - b.Property("Category") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("ImageData") - .HasColumnType("longblob"); - - b.Property("ImageMimeType") - .HasColumnType("longtext"); - - b.Property("ImageUrl") - .HasColumnType("longtext"); - - b.Property("Instructions") - .HasColumnType("longtext"); - - b.Property("IsAvailable") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProteinType") - .HasColumnType("longtext"); - - b.Property("RecipeUrl") - .HasColumnType("longtext"); - - b.Property("ThumbnailData") - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("Meals"); - }); - - modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CustomerName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IngredientsJson") - .HasColumnType("longtext"); - - b.Property("OrderedAt") - .HasColumnType("datetime(6)"); - - b.Property("PizzaName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PizzaOrders"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("PushSubscribers"); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("PushSubscriptions"); - }); - - modelBuilder.Entity("Aberwyn.Models.TodoTask", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedTo") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Tags") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("TodoTasks"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("NotifyBudget") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyMenu") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyPizza") - .HasColumnType("tinyint(1)"); - - b.HasKey("UserId"); - - b.ToTable("UserPreferences"); - }); - - modelBuilder.Entity("Aberwyn.Models.WeeklyMenu", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BreakfastMealId") - .HasColumnType("int"); - - b.Property("Cook") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DayOfWeek") - .HasColumnType("int"); - - b.Property("DinnerMealId") - .HasColumnType("int"); - - b.Property("LunchMealId") - .HasColumnType("int"); - - b.Property("WeekNumber") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WeeklyMenu", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.HasOne("Aberwyn.Models.BudgetCategoryDefinition", "Definition") - .WithMany() - .HasForeignKey("BudgetCategoryDefinitionId"); - - b.HasOne("Aberwyn.Models.BudgetPeriod", "BudgetPeriod") - .WithMany("Categories") - .HasForeignKey("BudgetPeriodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BudgetPeriod"); - - b.Navigation("Definition"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.HasOne("Aberwyn.Models.BudgetCategory", "BudgetCategory") - .WithMany("Items") - .HasForeignKey("BudgetCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.BudgetItemDefinition", "BudgetItemDefinition") - .WithMany() - .HasForeignKey("BudgetItemDefinitionId"); - - b.Navigation("BudgetCategory"); - - b.Navigation("BudgetItemDefinition"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.HasOne("Aberwyn.Models.Meal", null) - .WithMany("Ingredients") - .HasForeignKey("MealId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithOne("Preferences") - .HasForeignKey("Aberwyn.Models.UserPreferences", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Navigation("Preferences") - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Navigation("Items"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Navigation("Categories"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Navigation("Ingredients"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.cs b/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.cs deleted file mode 100644 index cd81a8d..0000000 --- a/Aberwyn/Migrations/20250606100439_AddPushSubscriberUserLink.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Aberwyn.Migrations -{ - public partial class AddPushSubscriberUserLink : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "UserId", - table: "PushSubscribers", - type: "varchar(255)", - nullable: false, - defaultValue: "") - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_PushSubscribers_UserId", - table: "PushSubscribers", - column: "UserId"); - - migrationBuilder.AddForeignKey( - name: "FK_PushSubscribers_AspNetUsers_UserId", - table: "PushSubscribers", - column: "UserId", - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_PushSubscribers_AspNetUsers_UserId", - table: "PushSubscribers"); - - migrationBuilder.DropIndex( - name: "IX_PushSubscribers_UserId", - table: "PushSubscribers"); - - migrationBuilder.DropColumn( - name: "UserId", - table: "PushSubscribers"); - } - } -} diff --git a/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.Designer.cs b/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.Designer.cs deleted file mode 100644 index aae57e5..0000000 --- a/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.Designer.cs +++ /dev/null @@ -1,821 +0,0 @@ -// -using System; -using Aberwyn.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Aberwyn.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250614211356_AddMealCategorySupport")] - partial class AddMealCategorySupport - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.36") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.AppSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AppSettings"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BudgetCategoryDefinitionId") - .HasColumnType("int"); - - b.Property("BudgetPeriodId") - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryDefinitionId"); - - b.HasIndex("BudgetPeriodId"); - - b.ToTable("BudgetCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategoryDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetCategoryDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("decimal(65,30)"); - - b.Property("BudgetCategoryId") - .HasColumnType("int"); - - b.Property("BudgetItemDefinitionId") - .HasColumnType("int"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("BudgetCategoryId"); - - b.HasIndex("BudgetItemDefinitionId"); - - b.ToTable("BudgetItems"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItemDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultCategory") - .HasColumnType("longtext"); - - b.Property("IncludeInSummary") - .HasColumnType("tinyint(1)"); - - b.Property("IsExpense") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("BudgetItemDefinitions"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Month") - .HasColumnType("int"); - - b.Property("Order") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("BudgetPeriods"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Item") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MealId") - .HasColumnType("int"); - - b.Property("Quantity") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("MealId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CarbType") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("ImageData") - .HasColumnType("longblob"); - - b.Property("ImageMimeType") - .HasColumnType("longtext"); - - b.Property("ImageUrl") - .HasColumnType("longtext"); - - b.Property("Instructions") - .HasColumnType("longtext"); - - b.Property("IsAvailable") - .HasColumnType("tinyint(1)"); - - b.Property("MealCategoryId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProteinType") - .HasColumnType("longtext"); - - b.Property("RecipeUrl") - .HasColumnType("longtext"); - - b.Property("ThumbnailData") - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.HasIndex("MealCategoryId"); - - b.ToTable("Meals"); - }); - - modelBuilder.Entity("Aberwyn.Models.MealCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Color") - .HasColumnType("longtext"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("DisplayOrder") - .HasColumnType("int"); - - b.Property("Icon") - .HasColumnType("longtext"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Slug") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("MealCategories"); - }); - - modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CustomerName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IngredientsJson") - .HasColumnType("longtext"); - - b.Property("OrderedAt") - .HasColumnType("datetime(6)"); - - b.Property("PizzaName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PizzaOrders"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("PushSubscribers"); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Auth") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Endpoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("P256DH") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("PushSubscriptions"); - }); - - modelBuilder.Entity("Aberwyn.Models.TodoTask", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedTo") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Tags") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("TodoTasks"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("NotifyBudget") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyMenu") - .HasColumnType("tinyint(1)"); - - b.Property("NotifyPizza") - .HasColumnType("tinyint(1)"); - - b.HasKey("UserId"); - - b.ToTable("UserPreferences"); - }); - - modelBuilder.Entity("Aberwyn.Models.WeeklyMenu", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BreakfastMealId") - .HasColumnType("int"); - - b.Property("Cook") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DayOfWeek") - .HasColumnType("int"); - - b.Property("DinnerMealId") - .HasColumnType("int"); - - b.Property("LunchMealId") - .HasColumnType("int"); - - b.Property("WeekNumber") - .HasColumnType("int"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("WeeklyMenu", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.HasOne("Aberwyn.Models.BudgetCategoryDefinition", "Definition") - .WithMany() - .HasForeignKey("BudgetCategoryDefinitionId"); - - b.HasOne("Aberwyn.Models.BudgetPeriod", "BudgetPeriod") - .WithMany("Categories") - .HasForeignKey("BudgetPeriodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BudgetPeriod"); - - b.Navigation("Definition"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetItem", b => - { - b.HasOne("Aberwyn.Models.BudgetCategory", "BudgetCategory") - .WithMany("Items") - .HasForeignKey("BudgetCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.BudgetItemDefinition", "BudgetItemDefinition") - .WithMany() - .HasForeignKey("BudgetItemDefinitionId"); - - b.Navigation("BudgetCategory"); - - b.Navigation("BudgetItemDefinition"); - }); - - modelBuilder.Entity("Aberwyn.Models.Ingredient", b => - { - b.HasOne("Aberwyn.Models.Meal", null) - .WithMany("Ingredients") - .HasForeignKey("MealId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.HasOne("Aberwyn.Models.MealCategory", "Category") - .WithMany("Meals") - .HasForeignKey("MealCategoryId"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Aberwyn.Models.StoredPushSubscription", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Aberwyn.Models.UserPreferences", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", "User") - .WithOne("Preferences") - .HasForeignKey("Aberwyn.Models.UserPreferences", "UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Aberwyn.Models.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.ApplicationUser", b => - { - b.Navigation("Preferences") - .IsRequired(); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetCategory", b => - { - b.Navigation("Items"); - }); - - modelBuilder.Entity("Aberwyn.Models.BudgetPeriod", b => - { - b.Navigation("Categories"); - }); - - modelBuilder.Entity("Aberwyn.Models.Meal", b => - { - b.Navigation("Ingredients"); - }); - - modelBuilder.Entity("Aberwyn.Models.MealCategory", b => - { - b.Navigation("Meals"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.cs b/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.cs deleted file mode 100644 index 0a41d0e..0000000 --- a/Aberwyn/Migrations/20250614211356_AddMealCategorySupport.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Aberwyn.Migrations -{ - public partial class AddMealCategorySupport : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Aberwyn/Migrations/ApplicationDbContextModelSnapshot.cs b/Aberwyn/Migrations/ApplicationDbContextModelSnapshot.cs index 1cc00ef..d98183d 100644 --- a/Aberwyn/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Aberwyn/Migrations/ApplicationDbContextModelSnapshot.cs @@ -342,6 +342,18 @@ namespace Aberwyn.Migrations b.HasKey("Id"); b.ToTable("MealCategories"); + + b.HasData( + new + { + Id = 1, + Color = "#f97316", + DisplayOrder = 1, + Icon = "🍕", + IsActive = true, + Name = "Pizza", + Slug = "pizza" + }); }); modelBuilder.Entity("Aberwyn.Models.PizzaOrder", b => @@ -391,12 +403,17 @@ namespace Aberwyn.Migrations .IsRequired() .HasColumnType("longtext"); + b.Property("PizzaOrderId") + .HasColumnType("int"); + b.Property("UserId") .IsRequired() .HasColumnType("varchar(255)"); b.HasKey("Id"); + b.HasIndex("PizzaOrderId"); + b.HasIndex("UserId"); b.ToTable("PushSubscribers"); @@ -706,12 +723,18 @@ namespace Aberwyn.Migrations modelBuilder.Entity("Aberwyn.Models.PushSubscriber", b => { + b.HasOne("Aberwyn.Models.PizzaOrder", "PizzaOrder") + .WithMany() + .HasForeignKey("PizzaOrderId"); + b.HasOne("Aberwyn.Models.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("PizzaOrder"); + b.Navigation("User"); }); diff --git a/Aberwyn/Models/PushSubscriber.cs b/Aberwyn/Models/PushSubscriber.cs index 31e86a9..dd81994 100644 --- a/Aberwyn/Models/PushSubscriber.cs +++ b/Aberwyn/Models/PushSubscriber.cs @@ -8,6 +8,9 @@ public string Auth { get; set; } public string UserId { get; set; } public virtual ApplicationUser User { get; set; } + public int? PizzaOrderId { get; set; } + public virtual PizzaOrder PizzaOrder { get; set; } + } public class PushMessageDto { diff --git a/Aberwyn/Views/User/Profile.cshtml b/Aberwyn/Views/User/Profile.cshtml index 23a60c4..6347da9 100644 --- a/Aberwyn/Views/User/Profile.cshtml +++ b/Aberwyn/Views/User/Profile.cshtml @@ -1,9 +1,10 @@ @model Aberwyn.Models.UserProfileViewModel @{ - ViewData["Title"] = "Userprofile"; + ViewData["Title"] = "Min profil"; }

Min profil

+
@@ -29,4 +30,108 @@
+ +
+
+ + +
+ +@section Scripts { + +} diff --git a/Aberwyn/wwwroot/js/site.js b/Aberwyn/wwwroot/js/site.js index 4e9d351..c56b640 100644 --- a/Aberwyn/wwwroot/js/site.js +++ b/Aberwyn/wwwroot/js/site.js @@ -6,7 +6,7 @@ if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/service-worker.js') .then(function (registration) { //console.log('✅ Service Worker registrerad med scope:', registration.scope); - subscribeToPush().catch(console.error); + //subscribeToPush().catch(console.error); }) .catch(function (error) { console.log('❌ Service Worker-registrering misslyckades:', error); @@ -127,6 +127,11 @@ async function subscribeToPush() { async function enablePush() { const permission = await Notification.requestPermission(); + const existingSub = await registration.pushManager.getSubscription(); + if (existingSub) { + alert("🔔 Du är redan prenumererad på notiser."); + return; + } if (permission !== "granted") { alert("Du måste tillåta notiser för att få push.");