【发布时间】:2014-01-31 13:04:29
【问题描述】:
我有一个连接到我的 MVC NopCommerce 应用程序中的按钮的方法。我只需要在调试器中得到结果,不需要在视图中显示结果。该方法位于 OrderServiceReport 类中。
问题是当我在控制器类中调用我的方法时,我得到:“方法没有重载需要 0 个参数”。认为我可能需要在此处添加参数?
这是我的代码..
IOrderReportService:
IList<BestsellersReportLine> DailyBestsellersReport(DateTime? startTime,
DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
int billingCountryId = 0,
int recordsToReturn = 5, int orderBy = 1, int groupBy = 1, bool showHidden = false);
OrderReportService 类:
public IList<BestsellersReportLine> DailyBestsellersReport(DateTime? startTime,
DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
int billingCountryId = 0,
int recordsToReturn = 5, int orderBy = 1, int groupBy = 1, bool showHidden = false)
{
int? orderStatusId = null;
if (os.HasValue)
orderStatusId = (int)os.Value;
int? paymentStatusId = null;
if (ps.HasValue)
paymentStatusId = (int)ps.Value;
int? shippingStatusId = null;
if (ss.HasValue)
shippingStatusId = (int)ss.Value;
var query1 = from opv in _opvRepository.Table
join o in _orderRepository.Table on opv.OrderId equals o.Id
join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id
join p in _productRepository.Table on pv.ProductId equals p.Id
where (!startTime.HasValue || startTime.Value <= o.CreatedOnUtc) &&
(!endTime.HasValue || endTime.Value >= o.CreatedOnUtc) &&
(!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) &&
(!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) &&
(!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) &&
(!o.Deleted) &&
(!p.Deleted) &&
(!pv.Deleted) &&
(billingCountryId == 0 || o.BillingAddress.CountryId == billingCountryId) &&
(showHidden || p.Published) &&
(showHidden || pv.Published)
select opv;
var query2 = groupBy == 1 ?
//group by product variants
from opv in query1
group opv by opv.ProductVariantId into g
select new
{
EntityId = g.Key,
TotalAmount = g.Sum(x => x.PriceExclTax),
TotalQuantity = g.Sum(x => x.Quantity),
}
:
//group by products
from opv in query1
group opv by opv.ProductVariant.ProductId into g
select new
{
EntityId = g.Key,
TotalAmount = g.Sum(x => x.PriceExclTax),
TotalQuantity = g.Sum(x => x.Quantity),
}
;
switch (orderBy)
{
case 1:
{
query2 = query2.OrderByDescending(x => x.TotalQuantity);
}
break;
case 2:
{
query2 = query2.OrderByDescending(x => x.TotalAmount);
}
break;
default:
throw new ArgumentException("Wrong orderBy parameter", "orderBy");
}
if (recordsToReturn != 0 && recordsToReturn != int.MaxValue)
query2 = query2.Take(recordsToReturn);
var result = query2.ToList().Select(x =>
{
var reportLine = new BestsellersReportLine()
{
EntityId = x.EntityId,
TotalAmount = x.TotalAmount,
TotalQuantity = x.TotalQuantity
};
return reportLine;
}).ToList();
return result;
}
订单控制器类:
public ActionResult SendDailyReport()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
return AccessDeniedView();
try
{
_orderReportService.DailyBestsellersReport();
}
catch (Exception ex)
{ }
return RedirectToAction("List");
}
查看:
<a href="@Url.Action("SendDailyReport")" class="t-button">@T("Admin.Common.DailyBestsellersSend.All")</a>
怎么了??
谢谢
【问题讨论】:
-
那构建?您在签名中有“可为空”的引用类型。
-
错误很明显,你试图调用一个带有一些参数的方法,但你没有传递任何参数。你的大部分代码与实际问题无关
标签: c# asp.net-mvc entity-framework nopcommerce