feat: complete mealplanner app (backend + frontend + deployment)
.NET 8 backend with Zitadel JWT auth, TheMealDB integration, weekly meal plan generation, shopping list aggregation. Vue 3 + Tailwind 4 frontend with dark emerald theme, manual OIDC PKCE auth, all views implemented. Multi-stage Dockerfile with nginx reverse proxy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
42
backend/Controllers/SettingsController.cs
Normal file
42
backend/Controllers/SettingsController.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MealPlanner.Data;
|
||||
using MealPlanner.Models;
|
||||
|
||||
namespace MealPlanner.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/settings")]
|
||||
[Authorize]
|
||||
public class SettingsController(AppDbContext db) : ControllerBase
|
||||
{
|
||||
private string UserId => User.FindFirst("sub")?.Value ?? throw new UnauthorizedAccessException();
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
var settings = await db.UserSettings.FindAsync(UserId);
|
||||
if (settings is null)
|
||||
{
|
||||
settings = new UserSettings { UserId = UserId, HouseholdSize = 2 };
|
||||
db.UserSettings.Add(settings);
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
return Ok(settings);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> Update([FromBody] UserSettings updated)
|
||||
{
|
||||
var settings = await db.UserSettings.FindAsync(UserId);
|
||||
if (settings is null)
|
||||
{
|
||||
settings = new UserSettings { UserId = UserId };
|
||||
db.UserSettings.Add(settings);
|
||||
}
|
||||
|
||||
settings.HouseholdSize = updated.HouseholdSize;
|
||||
await db.SaveChangesAsync();
|
||||
return Ok(settings);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user