Try to change your code as follows.
ViewModel:
public class BuddyViewModel
{
public BuddyShip BuddyShip {get; set;}
public List<Buddyship> AllBudees {get; set;}
public List<UserProperty> Users { get; set; } //** Add this property
}
Your action:
public ActionResult Index(int? id)
{
//I get logged in user properties
var user = db.UserProperties.SingleOrDefault(x => x.UserName == User.Identity.Name);
///**************Get Buddyships of current user*************************
List<Buddyship> allBudees = db1.Buddyships.Where(u =>u.BuddiedByUserId == user.UserId).ToList();
///**************Get Users supporting by user*************************
var buds =
(from u in db.UserProperties
join m in allBudees on u.UserId equals m.buddiedUserId
where m.BuddiedByUserId == user.UserId
select new UserProperty
{
FirstName = u.FirstName,
LastName = u.LastName,
SchoolName = u.SchoolName,
UserId = u.UserId
}).ToList();
var buddyviewmodel = new BuddyViewModel
{
Users = buds,
AllBudees = allBudees, //** if you really need this property in your View,
...
}
return View(buddyviewmodel);
}
Change View. In your action you are sending only one BuddyViewModel, which contains a list of UserProperties, but not a list of BuddyViewModels
@model BudTT.Models.BuddyViewModel
@foreach (var item in Model.Users)
{
<p>@item.FirstName</p>
<p>@item.LastName</p>
}