Ejemplo n.º 1
0
        public ActionResult NggCreate([DataSourceRequest] DataSourceRequest request, PiFGame pifgame)
        {
            Debug.WriteLine("Create Method Fired");

            // Perform model binding (fill the game properties and validate it).
            if (pifgame != null)
            {
                // if (pifgame.Count < 1)
                // {
                // pifgame.Count = 1;
                // }
                Game game = new PiFDbDataContext().Games.Single(g => g.id == pifgame.ID);

                if (game == null)
                {
                    ModelState.AddModelError("Name", "Invalid game name.");
                }
                else if (SessionNewGamesRepository.One(p => p.ID == game.id) != null)
                {
                    ModelState.AddModelError("Name", "Duplicate game, please edit existing row.");
                }
                else
                {
                    pifgame.PointWorth = game.PointWorth;
                    pifgame.SteamID = game.SteamID;
                    pifgame.Name = game.Name;
                    pifgame.ID = game.id;
                    SessionNewGamesRepository.Insert(pifgame);
                }
            }

            // Rebind the grid
            return Json(new[] { pifgame }.ToDataSourceResult(request, ModelState));
        }
        public ActionResult EggUpdate([DataSourceRequest] DataSourceRequest request, PiFGame pifgame)
        {
            // PiFGame pifgame = SessionEditGamesRepository.One(p => p.ID == id);
            if (pifgame != null && ModelState.IsValid)
            {
                Game game = GameHelper.GetGameList().FirstOrDefault(g => g.Name == pifgame.Name);
                if (game == null)
                {
                    ModelState.AddModelError("Name", "Invalid game name.");
                }
                else if (SessionEditGamesRepository.One(p => p.ID == game.id && game.id != pifgame.ID) != null)
                {
                    ModelState.AddModelError("Name", "Duplicate game, please edit existing row.");
                }
                else
                {
                    SessionEditGamesRepository.Delete(pifgame);
                    if (pifgame.Count > 0)
                    {
                        SessionEditGamesRepository.Insert(new PiFGame(pifgame.Count, game));
                    }
                }
            }

            return Json(ModelState.ToDataSourceResult());
        }
 public static void Delete(PiFGame game)
 {
     PiFGame target = One(p => p.ID == game.ID);
     if (target != null)
     {
         All().Remove(target);
     }
 }
Ejemplo n.º 4
0
        public ActionResult NggDelete([DataSourceRequest] DataSourceRequest request, PiFGame game)
        {
            // Delete the record
            SessionNewGamesRepository.Delete(game);

            // Rebind the grid
            return Json(ModelState.ToDataSourceResult());
        }
        public static void Update(PiFGame game)
        {
            PiFGame target = One(p => p.ID == game.ID);
            if (target == null)
            {
                return;
            }

            target.Name = game.Name;
            target.ID = game.ID;
            target.PointWorth = game.PointWorth;
            target.SteamID = game.SteamID;
            target.Count = game.Count;
        }
Ejemplo n.º 6
0
        public ActionResult NggUpdate([DataSourceRequest] DataSourceRequest request, PiFGame pifgame)
        {
            Debug.WriteLine("Update Method Fired");

            // PiFGame pifgame = SessionNewGamesRepository.One(p => p.ID == id);
            if (pifgame != null && ModelState.IsValid)
            {
                PiFGame target = SessionNewGamesRepository.One(g => g.ID == pifgame.ID);
                if (target != null)
                {
                    target.Name = pifgame.Name;
                    target.PointWorth = pifgame.PointWorth;
                    target.SteamID = pifgame.SteamID;
                    target.Count = pifgame.Count;
                    target.ID = pifgame.ID;
                    SessionNewGamesRepository.Update(target);
                }
            }

            return Json(ModelState.ToDataSourceResult());
        }
        public ActionResult EggCreate([DataSourceRequest] DataSourceRequest request, PiFGame pifgame)
        {
            // Perform model binding (fill the game properties and validate it).
            if (pifgame != null && ModelState.IsValid)
            {
                Game game = new PiFDbDataContext().Games.FirstOrDefault(g => g.Name == pifgame.Name);
                if (game == null)
                {
                    ModelState.AddModelError("Name", "Invalid game name.");
                }
                else if (SessionEditGamesRepository.One(p => p.ID == game.id) != null)
                {
                    ModelState.AddModelError("Name", "Duplicate game, please edit existing row.");
                }
                else
                {
                    pifgame = new PiFGame(pifgame.Count, game);
                    SessionEditGamesRepository.Insert(pifgame);
                }
            }

            // Rebind the grid
            return Json(new[] { pifgame }.ToDataSourceResult(request, ModelState));
        }
 /// <summary>Insert a game into the table.</summary>
 /// <param name="game">The game object to insert.</param>
 public static void Insert(PiFGame game)
 {
     All().Insert(0, game);
 }