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; } }
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; } }
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; } }
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; } }