I got this model in my project:
public class ListOfProducts
{
public List<string> ProductNames { get; set; }
public List<string> ProductUrls { get; set; }
}
The way I pass it to my view is:
public ActionResult Index()
{
var listOfUrls = GetListOfHrefs(); //Methods for giving values
var listOfProductNames = GetListOfProductNames();//Methods for giving values
var model = new ListOfProducts {ProductUrls = listOfUrls, ProductNames = listOfProductNames, ProductGtin = listofGti};
return View(model);
}
I would like to pass my model to the view as a list in order to loop through it the way i Want...Can I convert my model to a list before passing it?
Tried model.Tolist(
) but the intellisense could no find the Tolist-Part
EDIT:
I really need to acess both properties in the same context..In this case the Artice
<article id="post-62" class="post-62 x-portfolio type-x-portfolio status-publish has-post-thumbnail hentry has-post-thumbnail x-portfolio-5e9a5c5e0b6c2e1342bfccc9cacb084f x-portfolio-3ce959340d6fed7ed4f041884b46387c">
<div class="entry-wrap cf">
<header class="entry-header">
<h2 class="entry-title entry-title-portfolio">
<p>@product</p>
</h2>
</header>
</div>
<p>@url</p>
<span class="visually-hidden"><span class="author vcard"><span class="fn">addiadmin</span></span><span class="entry-title">Gluten & Mjölkfri Raggmunk</span><time class="entry-date updated" datetime="2014-05-21T08:23:32+00:00">05.21.2014</time></span>
</article>