Example #1
0
        public static void UpdateGameSet(int gameSetId, CreateGameSetViewModel viewModel)
        {
            viewModel.GameSetId = gameSetId;

            GameSet gameSet = _gamesRepo.GetGameSetById(gameSetId);

            if (gameSet == null)
            {
                throw new NotFoundEntityException("Game set with this Id doesn't exist");
            }

            GamesCycle gamesCycle = _gamesRepo.GetGameCycleById(viewModel.GameCycleId);

            if (gamesCycle == null)
            {
                throw new NotFoundEntityException("Game cycle with this Id doesn't exist");
            }
            if (!gamesCycle.IsPublished)
            {
                throw new NotFoundEntityException("Game cycle with this Id doesn't published");
            }

            gameSet.InjectFrom(viewModel);
            _gamesRepo.UpdateGameSet(gameSet);
        }
Example #2
0
        public IHttpActionResult UpdateGameSet(int gameSetId, [FromBody] CreateGameSetViewModel viewModel)
        {
            try
            {
                GamesService.UpdateGameSet(gameSetId, viewModel);

                return(Content(HttpStatusCode.OK, viewModel));
            }
            catch (NotFoundEntityException ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Example #3
0
        public IHttpActionResult CreateGameSet(CreateGameSetViewModel viewModel)
        {
            try
            {
                GameSetViewModel gameSetViewModel = GamesService.CreateGameSet(viewModel);

                return(Content(HttpStatusCode.Created, gameSetViewModel));
            }
            catch (NotFoundEntityException ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Example #4
0
        public static GameSetViewModel CreateGameSet(CreateGameSetViewModel viewModel)
        {
            GamesCycle gamesCycle = _gamesRepo.GetGameCycleById(viewModel.GameCycleId);

            if (gamesCycle == null)
            {
                throw new NotFoundEntityException("Game cycle with this Id doesn't exist");
            }
            if (!gamesCycle.IsPublished)
            {
                throw new NotFoundEntityException("Game cycle with this Id doesn't published");
            }

            GameSet gameSet = new GameSet();

            gameSet.InjectFrom(viewModel);
            _gamesRepo.AddGameSet(gameSet);

            GameSetViewModel gameSetViewModel = new GameSetViewModel();

            gameSetViewModel.InjectFrom(gameSet);

            return(gameSetViewModel);
        }