make views for testing data

This commit is contained in:
Francesco D'Amico
2025-03-30 15:56:17 +02:00
parent b2ba51d297
commit c48d1bb5b2
8 changed files with 201 additions and 8 deletions
@@ -0,0 +1,23 @@
@model Francesco.Recipes.World.Models.BackendModels.Category.Category
@{
ViewData["Title"] = "Category Details";
}
<h2>Category Details</h2>
<div>
<h4>Category</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
Name
</dt>
<dd class="col-sm-10">
@Model.Name
</dd>
</dl>
</div>
<div>
<a asp-action="Index" class="btn btn-primary">Back to List</a>
</div>
@@ -0,0 +1,28 @@
@model IEnumerable<Francesco.Recipes.World.Models.BackendModels.Category.Category>
@{
ViewData["Title"] = "Categories";
}
<h2>Categories</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var category in Model)
{
<tr>
<td>@category.Name</td>
<td>
<a asp-action="Details" asp-route-id="@category.Id" class="btn btn-primary">Details</a>
<a asp-action="Recipes" asp-route-id="@category.Id" class="btn btn-secondary">Recipes</a>
</td>
</tr>
}
</tbody>
</table>
@@ -1,8 +0,0 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@@ -0,0 +1,29 @@
@{
ViewData["Title"] = "Add or Create Ingredient to Recipe";
}
<h2>@ViewData["Title"]</h2>
<form asp-action="AddOrCreateIngredient" method="post">
<div class="form-group">
<label for="RecipeId" class="control-label">Recipe Id</label>
<input type="text" id="RecipeId" name="recipeId" class="form-control" />
</div>
<div class="form-group">
<label for="IngredientName" class="control-label">Ingredient Name</label>
<input type="text" id="IngredientName" name="ingredientName" class="form-control" />
</div>
<div class="form-group">
<label for="Quantity" class="control-label">Quantity</label>
<input type="number" id="Quantity" name="quantity" class="form-control" />
</div>
<div class="form-group">
<label for="UnitId" class="control-label">Unit</label>
<select id="UnitId" name="unitId" class="form-control" asp-items="ViewBag.Units"></select>
</div>
<button type="submit" class="btn btn-primary">Add Ingredient</button>
</form>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
@@ -0,0 +1,50 @@
@model Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe
@using Francesco.Recipes.World.Models.BackendModels.Recipe
@{
ViewData["Title"] = "Create Recipe";
}
<h1>Create Recipe</h1>
<form asp-action="Create" method="post">
<div class="form-group">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Description" class="control-label"></label>
<textarea asp-for="Description" class="form-control"></textarea>
<span asp-validation-for="Description" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Difficulty" class="control-label"></label>
<select asp-for="Difficulty" class="form-control" asp-items="Html.GetEnumSelectList<Difficulty>()"></select>
<span asp-validation-for="Difficulty" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Servings" class="control-label"></label>
<input asp-for="Servings" class="form-control" />
<span asp-validation-for="Servings" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PreparationTime" class="control-label"></label>
<input asp-for="PreparationTime" class="form-control" placeholder="hh:mm:ss" />
<span asp-validation-for="PreparationTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="CookingTime" class="control-label"></label>
<input asp-for="CookingTime" class="form-control" placeholder="hh:mm:ss" />
<span asp-validation-for="CookingTime" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
@section Scripts {
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
}
}
@@ -0,0 +1,36 @@
@model Francesco.Recipes.World.Views.Recipe.FilterByDifficultyViewModel
@using Francesco.Recipes.World.Models.BackendModels.Recipe
@{
ViewData["Title"] = "Filter Recipes by Difficulty";
}
<h1>Filter Recipes by Difficulty</h1>
<form asp-action="FilterByDifficulty" method="get">
<div class="form-group">
<label asp-for="SelectedDifficulty" class="control-label"></label>
<select asp-for="SelectedDifficulty" class="form-control" asp-items="Html.GetEnumSelectList<Difficulty>()"></select>
<span asp-validation-for="SelectedDifficulty" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-primary">Filter</button>
</form>
@if (Model.Recipes != null && Model.Recipes.Any())
{
<h2>Filtered Recipes</h2>
<ul>
@foreach (var recipe in Model.Recipes)
{
<li>@recipe.Name - @recipe.Difficulty</li>
}
</ul>
}
else
{
<p>No recipes found for the selected difficulty.</p>
}
@section Scripts {
@await Html.PartialAsync("_ValidationScriptsPartial")
}
@@ -0,0 +1,12 @@
namespace Francesco.Recipes.World.Views.Recipe
{
using System.Collections.Generic;
using Francesco.Recipes.World.Models.BackendModels.Recipe;
public class FilterByDifficultyViewModel
{
public Difficulty? SelectedDifficulty { get; set; }
public List<Recipe> Recipes { get; set; } = new List<Recipe>();
}
}
@@ -0,0 +1,23 @@
@model Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe
@{
ViewData["Title"] = "Remove Ingredient";
}
<h1>Remove Ingredient</h1>
<h3>Are you sure you want to remove the ingredient '@ViewBag.IngredientName' from this recipe?</h3>
<form asp-action="RemoveIngredientConfirmed" asp-route-categoryId="@ViewBag.CategoryId" asp-route-recipeId="@ViewBag.RecipeId" asp-route-ingredientId="@ViewBag.IngredientId" method="post">
<input type="hidden" name="categoryId" value="@ViewBag.CategoryId" />
<input type="hidden" name="recipeId" value="@ViewBag.RecipeId" />
<input type="hidden" name="ingredientId" value="@ViewBag.IngredientId" />
<div class="form-group">
<input type="submit" value="Remove" class="btn btn-danger" />
<a asp-action="Details" asp-route-id="@ViewBag.RecipeId" class="btn btn-secondary">Cancel</a>
</div>
</form>
@section Scripts {
@await Html.PartialAsync("_ValidationScriptsPartial")
}