コード例 #1
0
        public ActionResult Edit(int id)
        {
            var service  = CreateGameService();
            var pService = GetPlayerService();
            var tService = GetTeamService();

            var unsortedPlayerList = new SelectList(pService.GetPlayers(), "PlayerId", "LastName");
            var playerList         = unsortedPlayerList.OrderBy(o => o.Text);

            var unsortedTeamList = new SelectList(tService.GetTeams(), "TeamId", "TeamName");
            var teamList         = unsortedTeamList.OrderBy(o => o.Text);

            ViewBag.PlayerId   = playerList;
            ViewBag.HomeTeamId = teamList;
            ViewBag.AwayTeamId = teamList;


            var detail = service.GetGameById(id);
            var model  =
                new GameEdit
            {
                //HomeTeam = detail.HomeTeam,
                //AwayTeam = detail.AwayTeam,
                GameId     = detail.GameId,
                HomeTeamId = detail.HomeTeamId,
                AwayTeamId = detail.AwayTeamId,
                PlayerId   = detail.PlayerId,
            };

            return(View(model));
        }
コード例 #2
0
 public bool UpdateGame(GameEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         try
         {
             var entity = ctx.Games.Single(e => e.Id == model.GameId);
             entity.Title          = model.Title;
             entity.Description    = model.Description;
             entity.ParentalRating = model.ParentalRating;
             entity.GenreId        = model.GenreId;
             entity.DeveloperId    = model.DeveloperId;
             entity.PublisherId    = model.PublisherId;
             entity.Rating         = model.Rating;
             entity.ReleaseDate    = model.ReleaseDate;
             entity.ModifiedUtc    = DateTimeOffset.Now;
             return(ctx.SaveChanges() >= 1);
         }
         catch (Exception e)
         {
             Debug.Print("Exception thrown while looking for game");
             Debug.Print(e.Message);
             return(false);
         }
     }
 }
コード例 #3
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var platformQuery =
                    ctx.Platforms
                    .Where(p => model.PlatformNames.Contains(p.PlatformName))
                    .Select(
                        p =>
                        p.PlatformName
                        );

                var devEntity =
                    ctx.Developers
                    .Single(d => d.DeveloperName.ToLower() == model.DeveloperName.ToLower());

                var entity =
                    ctx.Games
                    .Find(model.GameID);

                entity.Title          = model.Title;
                entity.ReleaseDate    = model.ReleaseDate;
                entity.Genre          = model.Genre;
                entity.FirstSubgenre  = model.FirstSubgenre;
                entity.SecondSubgenre = model.SecondSubgenre;
                entity.ThirdSubgenre  = model.ThirdSubgenre;
                entity.Rating         = model.Rating;
                entity.Platforms      = platformQuery.ToList();
                entity.DeveloperID    = devEntity.DeveloperID;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #4
0
ファイル: GameService.cs プロジェクト: Evan-Lacy/HammerSpace
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Games.Single(e => e.GameId == model.GameId);
                entity.GameId          = model.GameId;
                entity.GameType        = model.GameType;
                entity.GameTitle       = model.GameTitle;
                entity.GameDescription = model.GameDescription;
                entity.AveragePlaytime = model.AveragePlaytime;
                entity.MinGamePlayers  = model.MinGamePlayers;
                entity.MaxGamePlayers  = model.MaxGamePlayers;

                if (model.GameType == GameType.BoardGame)
                {
                    ((BoardGame)entity).BoardGameGenre = model.BoardGameGenre;
                    ((BoardGame)entity).Category       = model.Category;
                    ((BoardGame)entity).BGPublisher    = model.BGPublisher;
                    ((BoardGame)entity).IsDiceGame     = model.IsDiceGame;
                    ((BoardGame)entity).IsCardGame     = model.IsCardGame;
                }
                else if (model.GameType == GameType.VideoGame)
                {
                    ((VideoGame)entity).VideoGameGenre = model.VideoGameGenre;
                    ((VideoGame)entity).LocalCoop      = model.LocalCoop;
                    ((VideoGame)entity).VGPublisher    = model.VGPublisher;
                    ((VideoGame)entity).Console        = model.Console;
                    ((VideoGame)entity).ESRBRating     = model.ESRBRating;
                }

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #5
0
ファイル: GameEdit.cs プロジェクト: RickyTong1024/snowball
 static void Execute()
 {
     if (window == null)
     {
         window = (GameEdit)GetWindow(typeof(GameEdit));
     }
     window.Show();
 }
コード例 #6
0
        public bool UpdateGame(GameEdit model)
        {
            var entity = _db.Games
                         .Single(x => x.GameID == model.GameID);

            entity.GameTitle    = model.GameTitle;
            entity.PlatformType = model.PlatformType;
            entity.CategoryType = model.CategoryType;
            entity.RatingType   = model.RatingType;
            entity.Price        = model.Price;

            return(_db.SaveChanges() == 1);
        }
コード例 #7
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.GameId == model.GameId && e.OwnerId == _userId);

                entity.GameTitle = model.GameTitle;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #8
0
        /// <summary>
        /// Allows you to get a game by its ID.
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        public IHttpActionResult Put(GameEdit game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateGameService();

            if (!service.UpdateGame(game))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
コード例 #9
0
        public ActionResult Edit(int id)
        {
            var service = CreateGameService();
            var detail  = service.GetGameById(id);
            var model   =
                new GameEdit
            {
                GameId      = detail.GameId,
                Title       = detail.Title,
                Genre       = detail.Genre,
                PlayerCount = detail.PlayerCount
            };

            return(View(model));
        }
コード例 #10
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Games.Single(g => g.GameId == model.GameId);

                entity.HomeTeamId = model.HomeTeamId;
                entity.AwayTeamId = model.AwayTeamId;
                entity.Date       = model.Date;
                // entity.HomeTeamScore = model.HomeTeamScore;
                // entity.AwayTeamScore = model.AwayTeamScore;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #11
0
        public void MapFromEdit()
        {
            var editGame = new GameEdit
            {
                Name       = "Edited Game",
                ReleasedOn = DateTime.Now
            };

            var game = _mapper.Map <Game>(editGame);

            game.Should()
            .NotBeNull("an object is always expected").And
            .BeOfType <Game>("it should be a Game").And
            .BeEquivalentTo(editGame, "it should have the same properties as the game we mapped from");
        }
コード例 #12
0
ファイル: GameController.cs プロジェクト: MSteele94/GamerHQ
        public ActionResult Edit(int id)
        {
            var service = CreateGameService();
            var detail  = service.GetGameById(id);
            var model   =
                new GameEdit
            {
                GameID     = detail.GameID,
                GameName   = detail.GameName,
                Genres     = detail.Genres,
                CreatedUtc = detail.CreatedUtc,
            };

            return(View(model));
        }
コード例 #13
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.GameID == model.GameID);
                entity.GameID     = model.GameID;
                entity.GameName   = model.GameName;
                entity.GenreType  = model.Genres;
                entity.CreatedUtc = model.CreatedUtc;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #14
0
        public IHttpActionResult Put(GameEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            GameService service = CreateGameService();

            if (service.UpdateExistingGame(model))
            {
                return(Ok());
            }

            return(InternalServerError());
        }
コード例 #15
0
        public ActionResult Edit(int id)
        {
            var service = CreateGameService();
            var detail  = service.GetGameByID(id);
            var model   = new GameEdit
            {
                GameID       = detail.GameID,
                GameTitle    = detail.GameTitle,
                PlatformType = detail.PlatformType,
                CategoryType = detail.CategoryType,
                RatingType   = detail.RatingType,
                Price        = detail.Price
            };

            return(View(model));
        }
コード例 #16
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.GameId == model.GameId && e.OwnerId == _userId);

                entity.Name        = model.Name;
                entity.Description = model.Description;
                entity.Price       = model.Price;
                entity.GenreTags   = model.GenreTags;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #17
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .VideoGame
                             .Single(e => e.GameId == model.GameId && e.OwnerId == _userId);

                entity.GameTitle   = model.GameTitle;
                entity.GenreType   = model.GenreType;
                entity.Console     = model.Console;
                entity.Price       = model.Price;
                entity.Quantity    = model.Quantity;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #18
0
        // GET: Edit Game
        public ActionResult Edit(int?id)
        {
            GameService service = new GameService();
            GameDetail  detail  = service.GetGameById(id);

            GameEdit game = new GameEdit()
            {
                Id                = detail.Id,
                Title             = detail.Title,
                Description       = detail.Description,
                PosterUrl         = detail.PosterUrl,
                ReleaseDate       = detail.ReleaseDate,
                DevStudio         = detail.DevStudio,
                AnticipationValue = detail.AnticipationValue
            };

            return(View(game));
        }
コード例 #19
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.GameId == model.GameId && e.OwnerId == _userId);

                entity.Name        = model.Name;
                entity.CategoryId  = model.CategoryId;
                entity.Category    = model.Category;
                entity.Developer   = model.Developer;
                entity.ReleaseYear = model.ReleaseYear;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #20
0
        // GET: Edit
        public ActionResult Edit(int id)
        {
            var svc    = CreateGameService();
            var detail = svc.GetGameByID(id);
            var model  = new GameEdit
            {
                GameID         = detail.GameID,
                Title          = detail.Title,
                ReleaseDate    = detail.ReleaseDate,
                Genre          = detail.Genre,
                FirstSubgenre  = detail.FirstSubgenre,
                SecondSubgenre = detail.SecondSubgenre,
                ThirdSubgenre  = detail.ThirdSubgenre,
                PlatformNames  = detail.PlatformNames,
                DeveloperName  = detail.DeveloperName
            };

            return(View(model));
        }
コード例 #21
0
        public IActionResult Update(string id, [FromBody] GameEdit game)
        {
            var model = GameRepository.Get(id);

            _mapper.Map(game, model);

            try
            {
                GameRepository.Update(id, model);
            }
            catch (Exception)         // TODO: Validar qual tipo de erro ocorreu
            {
                return(BadRequest()); // TODO: Com base na exception, decidir que resposta enviar.
            }

            _unitOfWork.SaveChanges();

            return(Ok());
        }
コード例 #22
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var game = ctx
                           .Games
                           .Single(g => g.Id == model.Id);

                game.PosterUrl         = model.PosterUrl;
                game.Title             = model.Title;
                game.Description       = model.Description;
                game.ReleaseDate       = model.ReleaseDate;
                game.DevStudio         = model.DevStudio;
                game.Genre             = model.Genre;
                game.AnticipationValue = model.AnticipationValue;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #23
0
 public ActionResult Edit(int id, GameEdit model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     if (model.GameId != id)
     {
         ModelState.AddModelError("", "Id Mismatch");
         return(View(model));
     }
     // var service = new GameService();
     if (_gameService.UpdateGame(model))
     {
         TempData["SaveResult"] = "The game was updated.";
         return(RedirectToAction("Index"));
     }
     ModelState.AddModelError("", "Game could not be updated.");
     return(View(model));
 }
コード例 #24
0
        public void UpdateGame()
        {
            var game = new GameEdit
            {
                Name       = "Pudim War",
                ReleasedOn = DateTime.Now
            };

            _mockRepository.Setup(m => m.Update(It.IsAny <string>(), It.IsAny <Game>()));
            _mockRepository.Setup(m => m.Get("gameId")).Returns(new Game {
                Id = "gameId", Name = "Old Name", ReleasedOn = DateTime.Now.AddYears(-7)
            });

            var result = _controller.Update("gameId", game);

            result.Should()
            .NotBeNull("a result is always expected").And
            .BeAssignableTo <IActionResult>("it should implement IActionResult").And
            .BeOfType <OkResult>("it should return OK");
        }
コード例 #25
0
        public bool UpdateGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.GameId == model.GameId && e.OwnerId == _userId);

                entity.HomeTeam   = (NamesOfTeams)model.HomeTeamId;
                entity.AwayTeam   = (NamesOfTeams)model.AwayTeamId;
                entity.HomeTeamId = model.HomeTeamId;
                entity.AwayTeamId = model.AwayTeamId;
                entity.PlayerId   = model.PlayerId;
                //entity.LastName = model.Player.LastName;
                entity.HomeTeamWin = model.HomeTeamWin;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #26
0
        public bool UpdateExistingGame(GameEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Games.FirstOrDefault(game => game.GameID == model.GameID && game.OwnerID == _userID);

                if (entity == null)
                {
                    return(false);
                }

                entity.DateOfGame  = model.DateOfGame;
                entity.HomeTeamID  = model.HomeTeamID;
                entity.AwayTeamID  = model.AwayTeamID;
                entity.StadiumID   = model.StadiumID;
                entity.HomeTeamWon = model.HomeTeamWon;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #27
0
        public IHttpActionResult Put(GameEdit model)

        {
            var service = CreateGameService();

            if (model == null)
            {
                return(BadRequest());
            }
            else
            {
                if (!service.UpdateGame(model))
                {
                    return(InternalServerError());
                }
                else
                {
                    return(Ok());
                }
            }
        }
コード例 #28
0
        public ActionResult Edit(int id)
        {
            var catService = CreateCategoryService();
            var category   = catService.GetCategories();
            var banana     = new SelectList(category, "categoryId", "Name");

            ViewBag.Category = banana;
            var service = CreateGameService();
            var detail  = service.GetGameById(id);
            var model   =
                new GameEdit
            {
                GameId      = detail.GameId,
                Name        = detail.Name,
                CategoryId  = detail.CategoryId,
                Category    = detail.Category,
                Developer   = detail.Developer,
                ReleaseYear = detail.ReleaseYear
            };

            return(View(model));
        }
コード例 #29
0
        //Edit the Game details, hopefully only getting the specific game requested
        public ActionResult Edit(int id)
        {
            var service = CreateGameService();
            var deet    = service.GetGameById(id);

            var model =
                new GameEdit
            {
                GameId          = deet.GameId,
                GameType        = deet.GameType,
                GameTitle       = deet.GameTitle,
                GameDescription = deet.GameDescription,
                AveragePlaytime = deet.AveragePlaytime,
                MinGamePlayers  = deet.MinGamePlayers,
                MaxGamePlayers  = deet.MaxGamePlayers,

                //Try one = match everything?
                //Matching Nulls should match in the background as the data table is filled with
                //them to store the blank items from the other kind of Game

                //Board Game
                BoardGameGenre = deet.BoardGameGenre,
                Category       = deet.Category,
                BGPublisher    = deet.BGPublisher,
                IsCardGame     = deet.IsCardGame,
                IsDiceGame     = deet.IsDiceGame,

                //Video Game
                VideoGameGenre = deet.VideoGameGenre,
                ESRBRating     = deet.ESRBRating,
                LocalCoop      = deet.LocalCoop,
                VGPublisher    = deet.VGPublisher,
                Console        = deet.Console
            };

            return(View(model));
        }
コード例 #30
0
        public ActionResult Edit(int id, GameEdit model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Could not update game, try again later");
                return(View(model));
            }

            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
            }

            GameService service = new GameService();

            if (service.UpdateGame(model))
            {
                TempData["SaveResult"] = $"{model.Title} was updated";
                return(RedirectToAction("AllGames"));
            }

            ModelState.AddModelError("", "Could not update game, try again later");
            return(View(model));
        }