public IHttpActionResult UpdateGameState(GamePutDto dto)
        {
            var response = _gameRepository.UpdateState(dto);

            if (response)
            {
                return(Ok());
            }
            return(NotFound());
        }
        public async Task <IActionResult> Update(GamePutDto dto)
        {
            var validationResult = await _app.Update(dto);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors.Select(x => x.ErrorMessage).ToList()));
            }

            return(NoContent());
        }
        public async Task <ValidationResult> Update(GamePutDto dto)
        {
            var game = await _uow.GameRepository.GetByIdAsync(dto.Id);

            game = UpdateMapper(game, dto);
            var validationResult = await _gameValidation.UpdateValidation.ValidateAsync(game);

            if (!validationResult.IsValid)
            {
                return(validationResult);
            }

            _uow.GameRepository.Edit(game);
            await _uow.CommitAsync();

            return(validationResult);
        }
Esempio n. 4
0
        public bool UpdateState(GamePutDto dto)
        {
            var game = Session.Get <GameModel>(dto.Id);

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

            using (var transaction = Session.BeginTransaction())
            {
                game.State = (GameState)dto.State;
                Session.Update(game);
                transaction.Commit();
            }
            return(true);
        }
        private Game UpdateMapper(Game game, GamePutDto dto)
        {
            game.Name = dto.Name;

            return(game);
        }