Initial commit

This commit is contained in:
2026-06-04 06:24:56 +02:00
commit 282f4864c4
111 changed files with 8083 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MealPlan.Api.Models;
/// <summary>
/// Maps to the existing ASP.NET Core Identity "AspNetUsers" table.
/// Only the columns described in the schema are mapped. Password verification uses
/// ASP.NET Core Identity's <see cref="Microsoft.AspNetCore.Identity.IPasswordHasher{TUser}"/>,
/// so no additional Identity tables are required for this read-only login flow.
/// </summary>
[Table("AspNetUsers")]
public class ApplicationUser
{
[Column("Id")]
public Guid Id { get; set; }
[Column("UserName")]
public string? UserName { get; set; }
[Column("Email")]
public string? Email { get; set; }
[Column("PasswordHash")]
public string? PasswordHash { get; set; }
[Column("CreatedAt")]
public DateTime CreatedAt { get; set; }
[Column("IsActive")]
public bool IsActive { get; set; }
}

View File

@@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MealPlan.Api.Models;
/// <summary>
/// Maps to the existing "Ingredients" table.
/// </summary>
[Table("Ingredients")]
public class Ingredient
{
[Column("Id")]
public int Id { get; set; }
[Column("RecipeId")]
public int RecipeId { get; set; }
[Column("Name")]
[MaxLength(255)]
public string Name { get; set; } = string.Empty;
[Column("AmountGrams")]
public decimal? AmountGrams { get; set; }
[Column("Unit")]
[MaxLength(50)]
public string? Unit { get; set; }
[Column("SortOrder")]
public int SortOrder { get; set; }
public Recipe? Recipe { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace MealPlan.Api.Models;
/// <summary>
/// Meal categories. Integer values map directly to the "MealCategory" column on "Recipes".
/// </summary>
public enum MealCategory
{
Breakfast = 0,
SecondBreakfast = 1,
Lunch = 2,
Dinner = 3
}

View File

@@ -0,0 +1,49 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MealPlan.Api.Models;
/// <summary>
/// Maps to the existing "Recipes" table. Database-first; no migrations manage this table.
/// </summary>
[Table("Recipes")]
public class Recipe
{
[Column("Id")]
public int Id { get; set; }
[Column("Name")]
[MaxLength(255)]
public string Name { get; set; } = string.Empty;
/// <summary>Stored as INT in the DB (0..3). Mapped to the <see cref="MealCategory"/> enum.</summary>
[Column("MealCategory")]
public int MealCategory { get; set; }
[Column("Calories")]
public int? Calories { get; set; }
[Column("Protein")]
public decimal? Protein { get; set; }
[Column("Fat")]
public decimal? Fat { get; set; }
[Column("Carbs")]
public decimal? Carbs { get; set; }
[Column("PrepTimeMinutes")]
public int? PrepTimeMinutes { get; set; }
[Column("CreatedAt")]
public DateTime CreatedAt { get; set; }
[Column("UpdatedAt")]
public DateTime? UpdatedAt { get; set; }
[Column("IsActive")]
public bool IsActive { get; set; }
public ICollection<Ingredient> Ingredients { get; set; } = new List<Ingredient>();
public ICollection<RecipeStep> Steps { get; set; } = new List<RecipeStep>();
}

View File

@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace MealPlan.Api.Models;
/// <summary>
/// Maps to the existing "RecipeSteps" table.
/// </summary>
[Table("RecipeSteps")]
public class RecipeStep
{
[Column("Id")]
public int Id { get; set; }
[Column("RecipeId")]
public int RecipeId { get; set; }
[Column("StepNumber")]
public int StepNumber { get; set; }
[Column("Description")]
public string Description { get; set; } = string.Empty;
public Recipe? Recipe { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace MealPlan.Api.Models;
/// <summary>
/// In-memory refresh token record. Stored in a singleton store rather than the database,
/// because the existing schema must not be modified and no migrations may be created.
/// Rotation: every successful refresh invalidates the previous token and issues a new one.
/// </summary>
public class RefreshToken
{
public string Token { get; set; } = string.Empty;
public string UserId { get; set; } = string.Empty;
public DateTime ExpiresAtUtc { get; set; }
public DateTime CreatedAtUtc { get; set; }
public bool IsRevoked { get; set; }
public bool IsActive => !IsRevoked && DateTime.UtcNow < ExpiresAtUtc;
}