37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using DrSousan.Api.Data;
|
||
|
|
using DrSousan.Api.Models;
|
||
|
|
|
||
|
|
namespace DrSousan.Api.Pages;
|
||
|
|
|
||
|
|
public class GalleryModel : PageModel
|
||
|
|
{
|
||
|
|
private readonly AppDbContext _db;
|
||
|
|
|
||
|
|
public GalleryModel(AppDbContext db) => _db = db;
|
||
|
|
|
||
|
|
public List<GalleryItem> Items { get; private set; } = new();
|
||
|
|
public List<string> Categories { get; private set; } = new();
|
||
|
|
|
||
|
|
public async Task OnGetAsync()
|
||
|
|
{
|
||
|
|
Items = await _db.GalleryItems
|
||
|
|
.Where(g => g.IsActive)
|
||
|
|
.OrderBy(g => g.Order)
|
||
|
|
.ToListAsync();
|
||
|
|
|
||
|
|
Categories = Items
|
||
|
|
.Where(i => !string.IsNullOrWhiteSpace(i.Category))
|
||
|
|
.Select(i => i.Category.Trim())
|
||
|
|
.Distinct()
|
||
|
|
.ToList();
|
||
|
|
|
||
|
|
var siteName = (await _db.SiteSettings
|
||
|
|
.FirstOrDefaultAsync(x => x.Section == "hero" && x.Key == "name"))?.Value
|
||
|
|
?? "دکتر سوسن آلطه";
|
||
|
|
ViewData["SiteName"] = siteName;
|
||
|
|
ViewData["Title"] = $"گالری نتایج قبل و بعد | {siteName}";
|
||
|
|
}
|
||
|
|
}
|