no overload for method takes 0 arguments, what am i missing?

I have a method iv'e connected to a button in my MVC NopCommerce application. I just need to get the result in the debugger, there's no need to display the result in the view. This method is located in OrderServiceReport class.

The promlem is that i get: "no overload for method takes 0 arguments" when i call my method in the controller class. Thinking i need to add the parameters here perhaps?

Here's my code..

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 class:

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;

    }

OrderController Class:

public ActionResult SendDailyReport()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            try
            {
                _orderReportService.DailyBestsellersReport();


            }
            catch (Exception ex)
            { }
            return RedirectToAction("List");
        }

View:

<a href="@Url.Action("SendDailyReport")" class="t-button">@T("Admin.Common.DailyBestsellersSend.All")</a>

What's wrong??

Thx

Answers


You have parameters without default values.

The fact that they are nullable doesn't change the fact that you need to put something for these arguments, when calling the method.

If you want to be able to call your method without adding parameters, use

IList<BestsellersReportLine> DailyBestsellersReport(DateTime? startTime = null,
    DateTime? endTime = null, OrderStatus? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null,
    int billingCountryId = 0,
    int recordsToReturn = 5, int orderBy = 1, int groupBy = 1, bool showHidden = false);

If you need to pass these parameters anyway, pass them when calling the method

xxx.DailyBestsellerReport(null, null, null, null, null)

no overload for method takes 0 arguments, what am i missing?

Arguments, like the error explains.

Arguments without a default value (= 42) need to be supplied a value, which may be null in case of nullable value types or reference types.

If you take a look at the generated WCF client proxy code (or however you call this service), you can see what arguments it expects and what overloads are available, if any.

From the interface, it looks like at least the first five expect a value:

_orderReportService.DailyBestsellersReport(null, null, null, null, null);

But I'm not sure the client you use also accepts this or that it requires all arguments to be set.

You might also want to consider using a data contract instead of so many arguments.


Need Your Help

Array inside an array(2 dimensional array) convert to string

php arrays string converter

How does one correctly/properly convert an array like this?