/// <summary> /// Get a formatted bestsellers total amount /// </summary> /// <param name="searchModel">Bestseller search model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the bestseller total amount /// </returns> public virtual async Task <string> GetBestsellerTotalAmountAsync(BestsellerSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } searchModel.Start = 0; searchModel.Length = int.MaxValue; //get parameters to filter bestsellers var orderStatus = searchModel.OrderStatusId > 0 ? (OrderStatus?)searchModel.OrderStatusId : null; var paymentStatus = searchModel.PaymentStatusId > 0 ? (PaymentStatus?)searchModel.PaymentStatusId : null; var currentVendor = await _workContext.GetCurrentVendorAsync(); if (currentVendor != null) { searchModel.VendorId = currentVendor.Id; } var startDateValue = !searchModel.StartDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()); var endDateValue = !searchModel.EndDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1); //get a total amount var totalAmount = await _orderReportService.BestSellersReportTotalAmountAsync( showHidden : true, createdFromUtc : startDateValue, createdToUtc : endDateValue, os : orderStatus, ps : paymentStatus, billingCountryId : searchModel.BillingCountryId, vendorId : searchModel.VendorId, categoryId : searchModel.CategoryId, manufacturerId : searchModel.ManufacturerId, storeId : searchModel.StoreId); return(await _priceFormatter.FormatPriceAsync(totalAmount, true, false)); }