f97f891d67
Full ASP.NET Core 10 Razor Pages app for آساد ابزار tool repair shop in Karaj, Iran (official DeWalt representative). Features: - Homepage, Services, DeWalt page, Shop (pagination + images) - 10 brand SEO pages (/brands/*) with rich Persian content + FAQ schema - Blog engine with admin management (/blog, /Admin/Blog) - Cart, Checkout, Contact (OpenStreetMap embed) - Admin panel: Products CRUD, Orders, Blog, Change Password - Jalali date formatting, product images, SiteData centralised contact - Docker + docker-compose with healthcheck - Gitea CI/CD via .gitea/workflows/ci-cd.yml (NuGet through Nexus mirror) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using AsadiTools.Data;
|
|
using AsadiTools.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace AsadiTools.Pages.Admin;
|
|
|
|
[Authorize(AuthenticationSchemes = "AdminCookie")]
|
|
public class AdminIndexModel(AppDbContext db) : PageModel
|
|
{
|
|
public int TotalOrders { get; private set; }
|
|
public int PendingOrders { get; private set; }
|
|
public decimal TotalRevenue { get; private set; }
|
|
public int ActiveProducts { get; private set; }
|
|
public List<Order> RecentOrders { get; private set; } = [];
|
|
|
|
public async Task<IActionResult> OnGetAsync()
|
|
{
|
|
TotalOrders = await db.Orders.CountAsync();
|
|
PendingOrders = await db.Orders.CountAsync(o => o.Status == OrderStatus.Pending);
|
|
TotalRevenue = await db.Orders.Where(o => o.Status != OrderStatus.Cancelled).SumAsync(o => o.Total);
|
|
ActiveProducts = await db.Products.CountAsync(p => p.IsActive);
|
|
RecentOrders = await db.Orders.OrderByDescending(o => o.Id).Take(6).ToListAsync();
|
|
return Page();
|
|
}
|
|
}
|