source: StockMaster/Controllers/HomeController.cs@ dfe03b8

main
Last change on this file since dfe03b8 was dfe03b8, checked in by Ceyda <ceyda.huseini@…>, 2 days ago

Initialize StockMaster project

  • Property mode set to 100644
File size: 1.4 KB
Line 
1using Microsoft.AspNetCore.Mvc;
2using StockMaster.Services;
3using StockMaster.ViewModels;
4using System;
5using System.Threading.Tasks;
6
7namespace StockMaster.Controllers
8{
9 public class HomeController : BaseController
10 {
11 private readonly IProductService _productService;
12 private readonly ISaleService _saleService;
13 private readonly IWarehouseService _warehouseService;
14
15 public HomeController(
16 IProductService productService,
17 ISaleService saleService,
18 IWarehouseService warehouseService)
19 {
20 _productService = productService;
21 _saleService = saleService;
22 _warehouseService = warehouseService;
23 }
24
25 public async Task<IActionResult> Index()
26 {
27 var viewModel = new DashboardViewModel
28 {
29 LowStockProducts = await _productService.GetLowStockProductsAsync(),
30 TotalSalesToday = await _saleService.GetTotalSalesAmountAsync(
31 DateTime.Today,
32 DateTime.Today.AddDays(1)),
33 TotalSalesMonth = await _saleService.GetTotalSalesAmountAsync(
34 new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)),
35 StockSummary = await _warehouseService.GetStockSummaryAsync()
36 };
37
38 return View(viewModel);
39 }
40 }
41}
Note: See TracBrowser for help on using the repository browser.