Ejemplo n.º 1
0
        public bool CreateJoiningTable(JoiningCreate model)
        {
            var entity =
                new JoiningTable()
            {
                UserID = model.UserID,
                GameID = model.GameID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.JoiningTables.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(JoiningCreate addGamesToUsers)
        {
            if (!ModelState.IsValid)
            {
                return(View(addGamesToUsers));
            }

            var service = CreateJoiningTableService();

            if (service.CreateJoiningTable(addGamesToUsers))
            {
                TempData["SaveResult"] = "You added a game to your account";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Game could not be added to account.");
            return(View(addGamesToUsers));
        }