| | | 1 | | using Microsoft.AspNetCore.Mvc; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using OzonOrdersWeb.Areas.Admin.OrderList; |
| | | 4 | | using OzonRepositories.Context; |
| | | 5 | | |
| | | 6 | | namespace OzonOrdersWeb.Areas.Admin.Controllers; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Главный экран административной панели. |
| | | 10 | | /// </summary> |
| | | 11 | | public class HomeController : AdminAreaControllerBase |
| | | 12 | | { |
| | | 13 | | private readonly ApplicationDbContext _db; |
| | | 14 | | |
| | 0 | 15 | | public HomeController(ApplicationDbContext db) |
| | | 16 | | { |
| | 0 | 17 | | _db = db; |
| | 0 | 18 | | } |
| | | 19 | | |
| | | 20 | | public async Task<IActionResult> Index(CancellationToken ct) |
| | | 21 | | { |
| | 0 | 22 | | ViewData["Title"] = "Обзор"; |
| | | 23 | | |
| | 0 | 24 | | ViewBag.RolesCount = await _db.AppRoles.CountAsync(ct); |
| | 0 | 25 | | ViewBag.UsersCount = await _db.UserAppRoles.Select(x => x.UserId).Distinct().CountAsync(ct); |
| | 0 | 26 | | ViewBag.PagesCount = await _db.AppPages.CountAsync(ct); |
| | 0 | 27 | | ViewBag.FieldsCount = await _db.AppFields.CountAsync(f => f.EntityName == OrderListColumnCatalog.EntityName, ct) |
| | 0 | 28 | | ViewBag.DataScopesCount = await _db.DataScopes.CountAsync(ct); |
| | 0 | 29 | | ViewBag.AuditCount = await _db.AuditLogEntries.CountAsync(ct); |
| | 0 | 30 | | ViewBag.RecentAudit = await _db.AuditLogEntries |
| | 0 | 31 | | .OrderByDescending(x => x.Timestamp) |
| | 0 | 32 | | .Take(10) |
| | 0 | 33 | | .ToListAsync(ct); |
| | | 34 | | |
| | 0 | 35 | | return View(); |
| | 0 | 36 | | } |
| | | 37 | | } |