ASP.NET MVC: How to transfer more than one object to View method?

Posted by ile on Stack Overflow See other posts from Stack Overflow or by ile
Published on 2010-03-20T21:30:57Z Indexed on 2010/03/20 21:41 UTC
Read the original article Hit count: 393

Filed under:
|
|
|
|

I finished NerdDinner tutorial and now I'm playing a bit with project. Index page shows all upcoming dinners:

    public ActionResult Index()
    {
        var dinners = dinnerRepository.FindUpComingDinners().ToList();
        return View(dinners);
    }

In DinnerRepository class I have method FindAllDinners and I would like to add to above Index method number of all dinners, something like this:

    public ActionResult Index()
    {
        var dinners = dinnerRepository.FindUpComingDinners().ToList();
        var numberOfAllDinners = dinnerRepository.FindAllDinners().Count();
        return View(dinners, numberOfAllDinners);
    }

Of course, this doesn't work. As I'm pretty new to OOP I would need help with this one.

Thanks,
Ile

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc