Files
Aberwyn/Aberwyn/Views/Meal/Meal.cshtml
2025-05-06 13:19:13 +02:00

78 lines
1.9 KiB
Plaintext

@model Aberwyn.Models.Meal
@{
ViewData["Title"] = Model.Id == 0 ? "Ny måltid" : Model.Name;
var isNew = Model.Id == 0;
}
<div class="meal-details">
<h1>@(isNew ? "Skapa ny måltid" : Model.Name)</h1>
<form asp-action="SaveMeal" method="post" enctype="multipart/form-data">
@if (!isNew)
{
<input type="hidden" name="Id" value="@Model.Id" />
}
<div>
<label for="Name">Namn</label>
<input type="text" name="Name" value="@Model.Name" required />
</div>
<div>
<label for="Description">Beskrivning</label>
<textarea name="Description">@Model.Description</textarea>
</div>
<div>
<label for="ProteinType">Protein</label>
<input type="text" name="ProteinType" value="@Model.ProteinType" />
</div>
<div>
<label for="CarbType">Kolhydrat</label>
<input type="text" name="CarbType" value="@Model.CarbType" />
</div>
<div>
<label for="RecipeUrl">Receptlänk</label>
<input type="url" name="RecipeUrl" value="@Model.RecipeUrl" />
</div>
<div>
<label for="ImageFile">Bild</label>
<input type="file" name="ImageFile" value="@Model.ImageUrl" />
</div>
<button type="submit">Spara</button>
</form>
</div>
<style>
.meal-details {
max-width: 600px;
margin: 2rem auto;
background: #f9f9f9;
padding: 2rem;
border-radius: 8px;
}
.meal-details label {
display: block;
font-weight: bold;
margin-top: 1rem;
}
.meal-details input[type=text],
.meal-details input[type=url],
.meal-details textarea {
width: 100%;
padding: 0.5rem;
border-radius: 4px;
border: 1px solid #ccc;
margin-top: 0.25rem;
}
.meal-details button {
margin-top: 1rem;
margin-right: 1rem;
}
</style>