Ejemplo n.º 1
0
        public GameOutput GetByKey(string key)
        {
            try
            {
                var game = new GetDeleteGameInput {
                    Key = key
                };
                var validationResults = _getDeleteGameValidator.Validate(game, "Key");

                if (!validationResults.IsValid)
                {
                    throw new ValidationException(validationResults.Errors);
                }

                var query = _unitOfWork.GetGamesFromAllDbs().Find(_ => _.Key == key).SingleOrDefault();
                return(Mapper.Map <GameOutput>(query));
            }
            catch (ValidationException exception)
            {
                _logger.Debug(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }
Ejemplo n.º 2
0
        public void Delete(string key)
        {
            try
            {
                var game = new GetDeleteGameInput {
                    Key = key
                };
                var validationResults = _getDeleteGameValidator.Validate(game, "Key");

                if (!validationResults.IsValid)
                {
                    throw new ValidationException(validationResults.Errors);
                }

                _unitOfWork.GetGamesFromAllDbs().Delete(key);
                _unitOfWork.Save();
            }
            catch (ValidationException exception)
            {
                _logger.Warn(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }
Ejemplo n.º 3
0
        public GameOutput Get(int id)
        {
            try
            {
                var game = new GetDeleteGameInput {
                    Id = id
                };
                var validationResults = _getDeleteGameValidator.Validate(game, "Id");

                if (!validationResults.IsValid)
                {
                    throw new ValidationException(validationResults.Errors);
                }

                var query = _unitOfWork.GetGamesFromAllDbs().Get(id);
                return(Mapper.Map <GameOutput>(query));
            }
            catch (ValidationException exception)
            {
                _logger.Debug(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }
Ejemplo n.º 4
0
        public IEnumerable <CommentOutput> GetByGameKey(string key)
        {
            try
            {
                var game = new GetDeleteGameInput {
                    Key = key
                };
                var validationResults = _getDeleteGameValidator.Validate(game, "Key");

                if (!validationResults.IsValid)
                {
                    throw new ValidationException(validationResults.Errors);
                }

                var query = _unitOfWork.GetComments().Find(_ => _.Game.Key == key).ToList();
                return(Mapper.Map <List <CommentOutput> >(query));
            }
            catch (ValidationException exception)
            {
                _logger.Warn(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }