Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters to method

I have js code where I pass data to repo method via parameters.

Here is repo method:

public List<SpeedLimitViewModel> GetSpeedData(decimal imei, DateTime start, DateTime end)
    {
        using (TraxgoDB ctx = new TraxgoDB())
        {
            List<SpeedLimitViewModel> alldata = new List<SpeedLimitViewModel>();
            var alllogs = ctx.Logging.OrderByDescending(x => x.LogID).ToList();

            for (int i = 1; i < alllogs.Count; i++)
            {
                alldata.Add(new SpeedLimitViewModel
                {
                    Imei= alllogs[i].Imei,
                    Latitude2 = alllogs[i].Latitude,
                    Longitude2 = alllogs[i].Longitude,
                    Speed = alllogs[i].Speed
                });
            }
            return alldata;
        }


    }

And I call this method in controller like this:

  public JsonResult SpeedData()
    {
        var speeddata = repoEntities.GetSpeedData();
        return Json(speeddata.ToArray(), JsonRequestBehavior.AllowGet);
    }

But I have error

Severity Code Description Project File Line Suppression State Error CS7036 There is no argument given that corresponds to the required formal parameter 'imei' of 'ReportsRepositoryEntities.GetSpeedData(decimal, DateTime, DateTime)' Traxgo.TrackerWeb C:\Users\EugeneSukhomlyn\Source\Workspaces\TraxgoWeb\Traxgo.TrackerWeb\Controllers\ReportsController.cs 94 Active

Where is my problem?


1 Answers

public JsonResult SpeedData(decimal imei, DateTime start, DateTime end)
    {
        var speeddata = repoEntities.GetSpeedData(imei, start, end);
        return Json(speeddata.ToArray(), JsonRequestBehavior.AllowGet);
    }
like image 179
Mike Avatar answered Dec 13 '25 04:12

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!