0

Me and my clients want to move to .NET so I still didn't get it to return more than 1 vars/strings in .NET. How to return something like this in .NET?

    //Verdienst für Heute ausrechnen
    $clicksToCoinsToday = Click::whereIn('short_link_id', $short_link_id)->whereDate('created_at', $today)->sum('click_amount');

    //Verdienst für letzte 7 Tage ausrechnen
    $clicksToCoinsLast7Days = Click::whereIn('short_link_id', $short_link_id)->whereDate('created_at', '>=', $lastweek)->sum('click_amount');

    return view('dashboard.admin.nutzerProfil', compact('nutzerDaten', 'clicksToCoinsYesterday', 'clicksToCoinsToday', 'clicksToCoinsLast7Days', 'allCoins'));

In C#

    public ActionResult GetClicks(List<Click> clicks, string clicksCount)
    {
        clicks =  _context.Clicks.ToList();

        clicksCount = _context.Clicks.Count().ToString();

        return (clicks, clicksCount);
    }

I wanted to get Clicks to List and also count how many of them are in DB.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

There are many ways to do this, I would recommend you should create a custom model representing the data needed for your view.

for example

public class ClicksViewModel
{
    public int ClicksCount{get;set;}
    public List<Clicks> Clicks{get;set;}
}

And then

return View(new ClicksViewModel(){ ClicksCount = clicksCount, Clicks = clicks });

In the view:

Model.ClicksCount;
Model.Clicks;
Andy Song
  • 4,404
  • 1
  • 11
  • 29