Merge
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Elias Jansson
2025-06-02 09:21:56 +02:00
parent 600df026d5
commit 3b0ea79748
2 changed files with 19 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Aberwyn.Models; using Aberwyn.Models;
using Aberwyn.Data;
namespace Aberwyn.Controllers namespace Aberwyn.Controllers
{ {
@@ -12,11 +12,22 @@ namespace Aberwyn.Controllers
{ {
private readonly UserManager<ApplicationUser> _userManager; private readonly UserManager<ApplicationUser> _userManager;
private readonly RoleManager<IdentityRole> _roleManager; private readonly RoleManager<IdentityRole> _roleManager;
private readonly IConfiguration _configuration;
private readonly IHostEnvironment _env;
private readonly ApplicationDbContext _context;
public AdminController(UserManager<ApplicationUser> userManager, RoleManager<IdentityRole> roleManager) public AdminController(
UserManager<ApplicationUser> userManager,
RoleManager<IdentityRole> roleManager,
IConfiguration configuration,
IHostEnvironment env,
ApplicationDbContext context)
{ {
_userManager = userManager; _userManager = userManager;
_roleManager = roleManager; _roleManager = roleManager;
_configuration = configuration;
_env = env;
_context = context;
} }
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
@@ -128,8 +139,6 @@ public IActionResult ImportMealsFromProd()
} }
[HttpPost] [HttpPost]
[Authorize(Roles = "Admin")] [Authorize(Roles = "Admin")]
[HttpPost]
[Authorize(Roles = "Admin")]
public IActionResult ImportMenusFromProd() public IActionResult ImportMenusFromProd()
{ {
var prodService = MenuService.CreateWithConfig(_configuration, _env, useProdDb: true); var prodService = MenuService.CreateWithConfig(_configuration, _env, useProdDb: true);

View File

@@ -157,6 +157,12 @@ public List<WeeklyMenu> GetAllWeeklyMenus()
.OrderBy(m => m.Name) .OrderBy(m => m.Name)
.ToList(); .ToList();
} }
public List<WeeklyMenu> GetWeeklyMenu(int weekNumber, int year)
{
return _context.WeeklyMenus
.Where(m => m.WeekNumber == weekNumber && m.Year == year)
.ToList();
}
public List<WeeklyMenu> GetMenuEntriesByDateRange(DateTime startDate, DateTime endDate) public List<WeeklyMenu> GetMenuEntriesByDateRange(DateTime startDate, DateTime endDate)
{ {