Fix admin route access and backend configuration
- Added /admin redirect to login page in nginx config - Fixed backend server.js route ordering for proper admin handling - Updated authentication middleware and routes - Added user management routes - Configured PostgreSQL integration - Updated environment configuration
This commit is contained in:
58
Sky_Art_shop/Controllers/PortfolioController.cs
Normal file
58
Sky_Art_shop/Controllers/PortfolioController.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SkyArtShop.Models;
|
||||
using SkyArtShop.Services;
|
||||
|
||||
namespace SkyArtShop.Controllers
|
||||
{
|
||||
public class PortfolioController : Controller
|
||||
{
|
||||
private readonly MongoDBService _mongoService;
|
||||
private readonly string _categoriesCollection = "PortfolioCategories";
|
||||
private readonly string _projectsCollection = "PortfolioProjects";
|
||||
|
||||
public PortfolioController(MongoDBService mongoService)
|
||||
{
|
||||
_mongoService = mongoService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var categories = await _mongoService.GetAllAsync<PortfolioCategory>(_categoriesCollection);
|
||||
var activeCategories = categories.Where(c => c.IsActive).OrderBy(c => c.DisplayOrder).ToList();
|
||||
|
||||
return View(activeCategories);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Category(string slug)
|
||||
{
|
||||
var categories = await _mongoService.GetAllAsync<PortfolioCategory>(_categoriesCollection);
|
||||
var category = categories.FirstOrDefault(c => c.Slug == slug && c.IsActive);
|
||||
|
||||
if (category == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var projects = await _mongoService.GetAllAsync<PortfolioProject>(_projectsCollection);
|
||||
var categoryProjects = projects
|
||||
.Where(p => p.CategoryId == category.Id && p.IsActive)
|
||||
.OrderBy(p => p.DisplayOrder)
|
||||
.ToList();
|
||||
|
||||
ViewBag.Category = category;
|
||||
return View(categoryProjects);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Project(string id)
|
||||
{
|
||||
var project = await _mongoService.GetByIdAsync<PortfolioProject>(_projectsCollection, id);
|
||||
|
||||
if (project == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user