// GET: Member public ActionResult Index(int?id, int?activityID, string searchString) { var viewModel = new MemberIndexData(); viewModel.Members = db.Members .OrderBy(m => m.LastName); if (id != null) { ViewBag.MemberID = id.Value; viewModel.Activities = viewModel.Members.Where( m => m.MemberID == id.Value).Single().Activities; } return(View(viewModel)); }
// GET: Members public async Task <IActionResult> Index(int?id) { var viewModel = new MemberIndexData(); viewModel.Members = await _context.Members .Include(m => m.Calling_Members) .ThenInclude(m => m.Calling) .AsNoTracking() .ToListAsync(); if (id != null) { ViewData["MemberId"] = id.Value; Member member = viewModel.Members .Where(m => m.MemberId == id.Value).Single(); viewModel.Callings = member.Calling_Members.Select(s => s.Calling); } return(View(viewModel)); }