public ActionResult Create(Game game) { if (ModelState.IsValid) { db.Game.Add(game); db.SaveChanges(); return RedirectToAction("Index"); } UserHandler userHandler = new UserHandler(); UserProfileInfo user = userHandler.GetUserLogged(); ViewBag.GameSerieID = new SelectList(user.GameSeries, "GameSerieID", "Name"); ViewBag.Players = new SelectList(user.Groups .Where(i => i.DominoesGroupID == user.GroupAdministered) .Select(i => i.Users).First(), "UserProfileInfoID", "FirstName"); return View(game); }
public ActionResult Edit(Game game) { if (ModelState.IsValid) { db.Entry(game).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } UserHandler userHandler = new UserHandler(); UserProfileInfo user = userHandler.GetUserLogged(); GameHandler GameHandler = new GameHandler(); ViewBag.GameSerieID = GameHandler.SelectGameSeries(user, game); ViewBag.Players = new SelectList(user.Groups .Where(i => i.DominoesGroupID == user.GroupAdministered) .Select(i => i.Users).First(), "UserProfileInfoID", "FirstName"); return View(game); }
public Game populateGame(Game Game, byte WinningTeam, string Category) { Game.GameComplete = true; Game.Date = DateTime.Now; Game.WinningTeam = WinningTeam; Game.WinningCategory = Category; return Game; }
public List<string> GetNamesInGame(Game game) { List<string> Names = new List<string>(); if (game.Player1 > 0) { Names.Add(db.UserProfileInfo.Where(i => i.UserProfileInfoID == game.Player1).Select(i => i.FirstName).Single()); } if (game.Player2 > 0) { Names.Add(db.UserProfileInfo.Where(i => i.UserProfileInfoID == game.Player2).Select(i => i.FirstName).Single()); } if (game.Player3 > 0) { Names.Add(db.UserProfileInfo.Where(i => i.UserProfileInfoID == game.Player3).Select(i => i.FirstName).Single()); } if (game.Player4 > 0) { Names.Add(db.UserProfileInfo.Where(i => i.UserProfileInfoID == game.Player4).Select(i => i.FirstName).Single()); } return Names; }
public IEnumerable<SelectListItem> SelectGameSeries(UserProfileInfo user, Game game) { var GameSeries = user.GameSeries.ToList(); IEnumerable<SelectListItem> selectList = from g in GameSeries select new SelectListItem { Selected = (g.GameSerieID == game.GameSerieID), Text = g.Name, Value = g.GameSerieID.ToString() }; return selectList; }