Example #1
0
        public GameDataBase DataEdit(GameDataBase newItem)
        {
            var o = ds.GameDatas.Include("Game").SingleOrDefault(v => v.Id == newItem.Id);

            ds.Entry(o).CurrentValues.SetValues(newItem);
            o.PlayerName = newItem.PlayerName;
            ds.SaveChanges();

            return(mapper.Map <GameDataBase>(o));
        }
Example #2
0
        public GameDataBase DataAdd(GameDataBase newItem)
        {
            var a = ds.Games.Find(newItem.GameId);

            if (a == null)
            {
                return(null);
            }
            else
            {
                var addedItem = ds.GameDatas.Add(mapper.Map <GameData>(newItem));
                addedItem.Game = a;
                ds.SaveChanges();

                return((addedItem == null) ? null : mapper.Map <GameDataBase>(addedItem));
            }
        }
Example #3
0
        public ActionResult AddData(int?id)
        {
            var a = m.GameById(id.GetValueOrDefault());

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var o = new GameDataBase();
                o.Category1 = a.Category1;
                o.Category2 = a.Category2;
                o.Category3 = a.Category3;
                o.Category4 = a.Category4;
                o.GameName  = a.Name;
                o.GameId    = a.Id;
                o.GameArt   = a.Art;
                return(View(o));
            }
        }
Example #4
0
        public ActionResult Edit(int?id, GameDataBase newItem)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("edit", new { id = newItem.GameId }));
            }

            var x = m.GameStats(id.GetValueOrDefault());

            // Attempt to do the update
            newItem.UploadDate = DateTime.Now.ToString("MMMM dd, yyyy, HH:mm");
            var editedItem = m.DataEdit(newItem);

            if (editedItem == null)
            {
                return(RedirectToAction("edit", new { id = newItem.GameId }));
            }
            else
            {
                return(RedirectToAction("details", new { id = newItem.GameId }));
            }
        }