save updated
This commit is contained in:
@@ -67,7 +67,7 @@ public class RecipeController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPut("update/{id}")]
|
||||
public async Task<IActionResult> UpdateRecipe(int id, [FromBody] Recipe updatedRecipe)
|
||||
public async Task<IActionResult> UpdateRecipe(int id, [FromBody] RecipeUpdateDto updatedRecipe)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RecipeController : ControllerBase
|
||||
|
||||
if (existingRecipe == null)
|
||||
{
|
||||
return NotFound("Recipe not found or you do not have permission to edit it.");
|
||||
return NotFound("Recipe not found or permission denied.");
|
||||
}
|
||||
|
||||
existingRecipe.Title = updatedRecipe.Title;
|
||||
@@ -88,6 +88,9 @@ public class RecipeController : ControllerBase
|
||||
existingRecipe.ImageUrl = updatedRecipe.ImageUrl;
|
||||
}
|
||||
|
||||
var fullText = $"{updatedRecipe.Title} {string.Join(" ", updatedRecipe.Ingredients)} {string.Join(" ", updatedRecipe.Instructions)}";
|
||||
existingRecipe.Embedding = await _recipeService.GetEmbeddingAsync(fullText);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(new { message = "Recipe updated successfully!" });
|
||||
|
||||
7
Seasoned.Backend/DTOs/RecipeUpdateDto.cs
Normal file
7
Seasoned.Backend/DTOs/RecipeUpdateDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
public class RecipeUpdateDto
|
||||
{
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<string> Ingredients { get; set; } = new();
|
||||
public List<string> Instructions { get; set; } = new();
|
||||
public string? ImageUrl { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user