コード例 #1
0
        /**
         * Redirects to page which provides information on the games including a detailed match history
         */
        public IActionResult GameDetail(string gameId)
        {
            string          currentChampion = _monthlyWinnersService.GetPastMonthWinnerWithGameId(gameId);
            ApplicationUser champion;
            var             currentChampionName = "No Winner Last Month";

            // If champion exists and their profile was not deleted
            if (currentChampion != null)
            {
                champion = _userService.GetById(currentChampion);
                if (champion != null && !champion.IsProfileDeleted)
                {
                    currentChampionName = champion?.UserName;
                }
            }

            var game             = _game.GetById(Int32.Parse(gameId));
            var MatchHistoryData = _userGameService.getUserGamesByGameId(gameId);
            IEnumerable <UserGameListingModel> GameSpecificMatchHistory = MatchHistoryData.OrderByDescending((x) => x.GamePlayedOn).Select((userGameItem) =>
            {
                UserGameListingModel model1 = new UserGameListingModel
                {
                    Id = userGameItem.Id,
                    //Game played Date
                    GamePlayedOn = userGameItem.GamePlayedOn,

                    //Players detail
                    User_01      = _userService.GetById(userGameItem.User_01_Id),
                    User_01_Team = userGameItem.User_01_Team,
                    User_02      = _userService.GetById(userGameItem.User_02_Id),
                    User_02_Team = userGameItem.User_02_Team,

                    // Game Name
                    GameName = userGameItem.GamePlayed.GameName,

                    //Score
                    GameScore = userGameItem.GameScoreUser01 + " : " + userGameItem.GameScoreUser02,

                    //Winner, “USER_01_Id”, “USER_02_Id”, “DRAW”
                    Winner = userGameItem.Winner,
                };
                return(model1);
            });

            var model = new GameDetailModel
            {
                GameDetail = game,
                GameSpecificMatchHistory = GameSpecificMatchHistory,
                ReigningChampion         = currentChampionName
            };

            return(View(model));
        }
コード例 #2
0
        public IHttpActionResult GetById(int id)
        {
            var game = this.data.Games.Find(id);

            if (game == null)
            {
                return(NotFound());
            }

            var gamesDetailModel = new GameDetailModel(game);

            return(Ok(gamesDetailModel));
        }
コード例 #3
0
        public IActionResult Edit(Guid id)
        {
            var game       = GetGame(id);
            var gameDetail = new GameDetailModel
            {
                id          = game.Id,
                Title       = game.Title,
                Description = game.Description,
                Rating      = game.Rating
            };

            return(View(gameDetail));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(GameDetailModel viewModel)
        {
            try
            {
                var gamedetail = GetGame(viewModel.id);
                gamedetail.Description = viewModel.Description;

                _context.Games.Update(gamedetail);
                await _context.SaveChangesAsync();

                return(Redirect($"~/Home"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            return(View(viewModel));
        }
コード例 #5
0
        public GameDetailModel GetGameDetail(int gameId)
        {
            var gameMasterService = new GameMasterService();
            var scoreService      = new ScoreService();


            var gameInfo = gameMasterService
                           .Select(new GameMasterEntity {
                GameId = gameId, GameTypeId = -1, ScoreType = -1, GameTime = -1
            })
                           .First();

            var score = scoreService.Select(new ScoreEntity {
                GameId = gameId, Score = -1
            });

            List <int> setScore = null;

            if (score != null)
            {
                setScore = gameInfo.ScoreType == 0
                    ? score.OrderByDescending(target => target.Score).Select(targert => targert.Score).Take(5).ToList()
                    : score.OrderBy(target => target.Score).Select(targert => targert.Score).Take(5).ToList();
            }

            var gameDetailModel = new GameDetailModel
            {
                Class    = gameInfo.Class,
                GameId   = gameId,
                GameName = gameInfo.GameName,
                Icon     = gameInfo.IconImage,
                Score    = setScore,
                Title    = gameInfo.TitleImage
            };

            return(gameDetailModel);
        }