public ActionResult AddOwnedGame(int GameId, string UserId) { var model = new UserOwnedGame(); model.GameId = GameId; model.UserId = UserId; return(View(model)); }
public ActionResult AddOwnedGame(UserOwnedGame model) { var search = db.UserOwnedGames.Find(model.GameId, model.UserId); if (search == null) { db.UserOwnedGames.Add(model); } var gameToUpdate = db.Games.Find(model.GameId); int solded = gameToUpdate.getSold(); gameToUpdate.setSold(solded + 1); db.Games.AddOrUpdate(gameToUpdate); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }