main
| Line | |
|---|
| 1 | using Microsoft.AspNetCore.Authorization;
|
|---|
| 2 | using Microsoft.AspNetCore.Mvc;
|
|---|
| 3 | using Microsoft.EntityFrameworkCore;
|
|---|
| 4 | using StockMaster.Data;
|
|---|
| 5 |
|
|---|
| 6 | namespace StockMaster.Controllers
|
|---|
| 7 | {
|
|---|
| 8 | [Authorize]
|
|---|
| 9 | public class DashboardController : Controller
|
|---|
| 10 | {
|
|---|
| 11 | private readonly StockDbContext _context;
|
|---|
| 12 | public DashboardController(StockDbContext context) => _context = context;
|
|---|
| 13 |
|
|---|
| 14 | public IActionResult Index()
|
|---|
| 15 | {
|
|---|
| 16 | ViewBag.Products = _context.Products.Count();
|
|---|
| 17 | ViewBag.TodaySales = _context.Sales.Where(s => s.DateTime.Date == DateTime.Today).Sum(s => s.TotalAmount);
|
|---|
| 18 | return View();
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.