@model WeekPlannerViewModel @{ ViewData["Title"] = "Week Planner"; }

📅 Week Planner

Debug: Model is @(Model == null ? "NULL" : "NOT NULL")

@if (Model != null) {

StartDate: @Model.StartDate

CurrentWeekPlan is @(Model.CurrentWeekPlan == null ? "NULL" : "NOT NULL")

}
@if (Model?.CurrentWeekPlan == null) {

No meal plan for this week yet!

Create a new week plan to start planning your meals.

} else {

@Model!.CurrentWeekPlan!.Name

Week of @Model!.StartDate.ToString("MMMM dd, yyyy")

@foreach (var dayPlan in Model!.CurrentWeekPlan!.DayPlans.OrderBy(dp => dp.Date)) {
@dayPlan.DayOfWeek
@dayPlan.Date.ToString("MMM dd")
@if (dayPlan.Recipe != null) {
@dayPlan.Recipe.Title
@if (!string.IsNullOrEmpty(dayPlan.MainIngredient)) { @dayPlan.MainIngredient } @if (!string.IsNullOrEmpty(dayPlan.Recipe.Time)) { @dayPlan.Recipe.Time min }

@(dayPlan.Recipe.Description?.Length > 80 ? dayPlan.Recipe.Description.Substring(0, 80) + "..." : dayPlan.Recipe.Description)

} else {

No recipe selected

@if (!string.IsNullOrEmpty(dayPlan.MainIngredient)) { @dayPlan.MainIngredient }
}
}
}