public ActionResult Register() { RegisterViewModel regViewModel = new RegisterViewModel(); List<UserRecreation> userRecList = new List<UserRecreation>(); foreach (var rec in db.Recreations) { UserRecreation ur = new UserRecreation(); ur.RecreationID = rec.RecreationID; ur.RecreationLabel = rec.Label; userRecList.Add(ur); } regViewModel.RecOptions = userRecList; return View(regViewModel); }
// // GET: /Manage/ChangeActivities public ActionResult ChangeActivities() { var userId = User.Identity.GetUserId(); List<UserRecreation> userRecList = new List<UserRecreation>(); List<Recreation> recs = db.Recreations.ToList(); var userRecs = db.UserRecreations.Where(u => u.User == userId); foreach (var rec in recs) { UserRecreation ur = new UserRecreation(); ur.RecreationID = rec.RecreationID; ur.RecreationLabel = rec.Label; // If they already have this rec type, make the box checked already. //var r = db.UserRecreations.Where(u => u.User == userId && u.RecreationID == rec.RecreationID); if (userRecs.Where(u => u.RecreationID == rec.RecreationID).Count() > 0) { ur.IsChecked = true; } userRecList.Add(ur); } var model = new ChangeActivitiesViewModel { RecOptions = userRecList }; return View(model); }