public async Task <IActionResult> LowStockReportList(DataSourceRequest command) { string vendorId = ""; //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !await _groupService.IsStaff(_workContext.CurrentCustomer)) { vendorId = _workContext.CurrentVendor.Id; } string storeId = ""; if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { storeId = _workContext.CurrentCustomer.StaffStoreId; } var lowStockProducts = await _productsReportService.LowStockProducts(vendorId, storeId); var models = new List <LowStockProductModel>(); //products foreach (var product in lowStockProducts.products) { var lowStockModel = new LowStockProductModel { Id = product.Id, Name = product.Name, ManageInventoryMethod = product.ManageInventoryMethodId.GetTranslationEnum(_translationService, _workContext.WorkingLanguage.Id), StockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true), Published = product.Published }; models.Add(lowStockModel); } //combinations foreach (var combination in lowStockProducts.combinations) { var product = await _productService.GetProductById(combination.ProductId); var lowStockModel = new LowStockProductModel { Id = product.Id, Name = product.Name, Attributes = await _productAttributeFormatter.FormatAttributes(product, combination.Attributes, _workContext.CurrentCustomer, "<br />", true, true, true, false), ManageInventoryMethod = product.ManageInventoryMethodId.GetTranslationEnum(_translationService, _workContext.WorkingLanguage.Id), StockQuantity = combination.StockQuantity, Published = product.Published }; models.Add(lowStockModel); } var gridModel = new DataSourceResult { Data = models.PagedForCommand(command), Total = models.Count }; return(Json(gridModel)); }
private async Task <DashboardActivityModel> PrepareActivityModel() { var model = new DashboardActivityModel(); string vendorId = ""; if (_workContext.CurrentVendor != null) { vendorId = _workContext.CurrentVendor.Id; } var storeId = string.Empty; if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { storeId = _workContext.CurrentCustomer.StaffStoreId; } model.OrdersPending = (await _orderReportService.GetOrderAverageReportLine(storeId: storeId, os: (int)OrderStatusSystem.Pending)).CountOrders; model.AbandonedCarts = (await _mediator.Send(new GetCustomerQuery() { StoreId = storeId, LoadOnlyWithShoppingCart = true })).Count(); var lowStockProducts = await _productsReportService.LowStockProducts(vendorId, storeId); model.LowStockProducts = lowStockProducts.products.Count + lowStockProducts.combinations.Count; model.MerchandiseReturns = await _mediator.Send(new GetMerchandiseReturnCountQuery() { RequestStatusId = 0, StoreId = storeId }); model.TodayRegisteredCustomers = (await _mediator.Send(new GetCustomerQuery() { StoreId = storeId, CustomerGroupIds = new string[] { (await _groupService.GetCustomerGroupBySystemName(SystemCustomerGroupNames.Registered)).Id }, CreatedFromUtc = DateTime.UtcNow.Date })).Count(); return(model); }