// [Authorize(Roles = "Quản trị viên")] public IActionResult Index() { // tính tổng sản phẩm đã bán tháng trước và tháng hiện tại int sumPre = 0; int sum = 0; //int preMonth = DateTime.Now.AddMonths(-1).Month; //List<DonHang> dhs = _repository.GetDonHangs(); //foreach (var item in dhs) //{ // if (item.NgayDatMua.Value.Month == preMonth) // { // foreach (var i in _repository.GetChiTietDonHangsByMaDH(item.MaDh) /*context.ChiTietDonHang.Where(x=>x.MaDh == item.MaDh)*/) // { // sumPre = sumPre + i.SoLuong.Value; // } // } // else if (item.NgayDatMua.Value.Month == DateTime.Now.Month) // { // foreach (var i in _repository.GetChiTietDonHangsByMaDH(item.MaDh)) // { // sum = sum + i.SoLuong.Value; // } // } //} ViewData["sumPreMonth"] = _spService.GetTotalProductSellPreMonth(); ViewData["sumCurMonth"] = _spService.GetTotalProductSellCurrentMonth(); //ViewData["sumPreMonth"] = _sanPhamService.GetTotalProductSellPreMonth(); //ViewData["sumCurMonth"] = _sanPhamService.GetTotalProductSellCurrentMonth(); return(View()); }