Files
SkyArtShop/Sky_Art_shop/Controllers/PortfolioController.cs
Local Server 703ab57984 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
2025-12-13 22:34:11 -06:00

59 lines
2.0 KiB
C#

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);
}
}
}