I currently have a model that is passing a dogs variable into the view:
public ActionResult Summary()
{
var dogs = repository.GetAllRecords().OrderByDescending(x => x.DateRecieved);
return View("Summary", dogs);
}
This has a field in it called OutcomeID, which references another array by ID:
var categories = new List<Category>();
try
{
this.Connect();
var cmd = new SqlCommand
{
CommandText = "dbo.GetSummaryOutcomes",
CommandType = CommandType.StoredProcedure,
Connection = this.cn
};
var result = cmd.ExecuteReader();
while (result.Read())
{
categories.Add(new Category
{
Name = result["Outcome"].ToString(),
Value = result["id"].ToString(),
InUse = bool.Parse(result["InUse"].ToString())
});
}
}
Is there anyway so that on my view I can combine these, and instead of just having the OutcomeID, I reference the Outcome result from the categories list?
ie I need to get result["Outcome"]
based on matching dogs.OutcomeID
to result["id"]
Sorry if this sounds like a silly question, in PHP this wouldn't be a problem for me, but I'm very new to ASP.NET MVC and I'm not sure where to begin
Thank you