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); } }
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)); }