Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
@using CulinaryCommand.Services
@using CulinaryCommand.Data.Enums;
@using CulinaryCommand.Services.UserContextSpace
@using CulinaryCommandApp.Recipe.Services;
@using CulinaryCommandApp.Recipe.Services.Interfaces;
@using CulinaryCommandApp.Recipe.Entities;
@inject IUserContextService UserCtx
@inject NavigationManager Nav
@inject ILocationService LocationService
@inject IUserService UserService
@inject LocationState LocationState
@inject ITaskAssignmentService TaskService
@inject IRecipeService RecipeService
@inject RecipeService RecipeService

@implements IDisposable
@rendermode InteractiveServer
Expand Down Expand Up @@ -349,8 +346,11 @@ else

try
{
recipes = await RecipeService.GetAllByLocationIdAsync(selectedLocationId.Value);
recipes = recipes.OrderBy(r => r.Title).ToList();
var all = await RecipeService.GetAllAsync();
recipes = all
.Where(r => r.LocationId == selectedLocationId.Value)
.OrderBy(r => r.Title)
.ToList();
}
catch
{
Expand Down
64 changes: 0 additions & 64 deletions CulinaryCommandApp/Components/Pages/EmployeeView.razor

This file was deleted.

31 changes: 31 additions & 0 deletions CulinaryCommandApp/Components/Pages/Recipes/Create.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@page "/recipes/create"
@using CulinaryCommand.Data.Entities
@inject NavigationManager Nav
@inject RecipeService Recipes
@inject LocationState LocationState
@rendermode InteractiveServer

<h3>Create Recipe</h3>

<RecipeForm Model="model" FormTitle="Create Recipe" OnValidSubmit="Save" />

@code {
private Recipe model = new();

private async Task Save()
{
// Make sure we have a current location
if (LocationState.CurrentLocation is null)
{
// You can swap this for a nicer UI message later
Console.WriteLine("No current location selected – cannot save recipe.");
return;
}

// 🔥 attach recipe to the active location
model.LocationId = LocationState.CurrentLocation.Id;

await Recipes.CreateAsync(model);
Nav.NavigateTo("/recipes");
}
}
33 changes: 33 additions & 0 deletions CulinaryCommandApp/Components/Pages/Recipes/Edit.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@page "/recipes/edit/{id:int}"
@using CulinaryCommand.Data.Entities
@inject NavigationManager Nav
@inject RecipeService Recipes
@rendermode InteractiveServer

<h3>Edit Recipe</h3>

@if (model == null)
{
<p>Loading...</p>
}
else
{
<RecipeForm Model="model" FormTitle="Edit Recipe" OnValidSubmit="Save" />
}

@code {
[Parameter] public int id { get; set; }

private Recipe? model;

protected override async Task OnInitializedAsync()
{
model = await Recipes.GetByIdAsync(id);
}

private async Task Save()
{
await Recipes.UpdateAsync(model);
Nav.NavigateTo("/recipes");
}
}
5 changes: 5 additions & 0 deletions CulinaryCommandApp/Components/Pages/Recipes/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/recipes"
@using CulinaryCommand.Data.Entities
@rendermode InteractiveServer

<RecipeList />
Loading
Loading