This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Aberwyn.Models;
|
||||
|
||||
using Aberwyn.Data;
|
||||
|
||||
namespace Aberwyn.Controllers
|
||||
{
|
||||
@@ -12,11 +12,22 @@ namespace Aberwyn.Controllers
|
||||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
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;
|
||||
_roleManager = roleManager;
|
||||
_configuration = configuration;
|
||||
_env = env;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
@@ -128,8 +139,6 @@ public IActionResult ImportMealsFromProd()
|
||||
}
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin")]
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public IActionResult ImportMenusFromProd()
|
||||
{
|
||||
var prodService = MenuService.CreateWithConfig(_configuration, _env, useProdDb: true);
|
||||
|
||||
@@ -157,6 +157,12 @@ public List<WeeklyMenu> GetAllWeeklyMenus()
|
||||
.OrderBy(m => m.Name)
|
||||
.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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user