All thread resolved

This commit is contained in:
franc
2025-04-10 10:23:43 +02:00
parent 127a60b621
commit 603dc4a2c6
8 changed files with 23 additions and 24 deletions
@@ -45,7 +45,7 @@
}
[HttpPost("ReplaceInstructionImage")]
[ValidateAntiForgeryToken]
[AutoValidateAntiforgeryToken]
public async Task<IActionResult> ReplaceInstructionImage(Guid instructionId, Guid mediaFileIdToReplace, IFormFile? newPhoto)
{
if (newPhoto is null)
@@ -4,7 +4,6 @@
using Francesco.Recipes.World.Models;
using Francesco.Recipes.World.Repositories.ShoppingList;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
public class ShoppingListController : Controller
{
@@ -21,17 +20,17 @@
[ValidateAntiForgeryToken]
public async Task<IActionResult> CreateOrAddIngredients([FromBody] CreateOrAddIngredientRequestModel request)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (request == null || request.IngredientIds == null || !request.IngredientIds.Any())
{
return BadRequest("No ingredients provided.");
}
await _shoppingListRepository.AddIngredientsToShoppingListAsync(request.RecipeId, request.IngredientIds);
var shoppingList = await _context.ShoppingLists
.Include(sl => sl.RecipeShoppingList)
.ThenInclude(rsl => rsl.Recipe)
.FirstOrDefaultAsync(sl => sl.RecipeShoppingList.Any(rsl => rsl.Recipe.Id == request.RecipeId));
var shoppingList = await _shoppingListRepository.AddIngredientsToShoppingListAsync(request.RecipeId, request.IngredientIds);
if (shoppingList == null)
{