public ActionResult GamesSelection(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Member member = db.Members.Find(id);

            if (member == null)
            {
                return(HttpNotFound());
            }
            MemberGamesSelectionVM mgsm = new MemberGamesSelectionVM();

            mgsm.Member = member;
            foreach (Game g in db.Games.ToList())
            {
                /*
                 * SelectableGame sg = new SelectableGame();
                 * sg.Id = g.Id;
                 * sg.Title = g.Title;
                 * sg.isSelected = member.Games.Contains(g);
                 *
                 */
                mgsm.SelectableGames.Add(new SelectableGame()
                {
                    Id         = g.Id,
                    Title      = g.Title,
                    isSelected = member.Games.Contains(g)
                });
            }

            return(View(mgsm));
        }
        public ActionResult GamesSelection(MemberGamesSelectionVM mgsm)
        {
            if (ModelState.IsValid)
            {
                Member member = db.Members.Find(mgsm.Member.Id);
                db.Entry(member).State = EntityState.Modified;

                foreach (SelectableGame sg in mgsm.SelectableGames)
                {
                    Game g = db.Games.Find(sg.Id);
                    if (sg.isSelected)
                    {
                        member.Games.Add(g);
                    }
                    else
                    {
                        member.Games.Remove(g);
                    }
                }
            }
            return(View(mgsm));
        }