public bool CreateExternalExchange(IDbConnection db, external_exchange external_exchange) { string sqlQuery = @" INSERT INTO external_exchange( customer_account_id, game_id, package_id, credit_type_id, exchange_option_identifier, transaction_id) VALUES ( @customer_account_id, @game_id, @package_id, @credit_type_id, @exchange_option_identifier, @transaction_id)"; return 1 == db.Execute(sqlQuery, external_exchange); }
public bool CreateExternalExchange(external_exchange externalExchange) { var repo = Repo.Instance; using (var db = repo.OpenConnectionFromPool()) { return repo.CreateExternalExchange(db, externalExchange); } }
public object UpdateExternalExchange() { var request = HttpContext.Current.Request; GoPlayApi api = GoPlayApi.Instance; string gameUid = request.Params["game_id"]; Game game = api.GetGame(gameUid).Data; //string session = request.Params["session"]; string session = !string.IsNullOrEmpty(request.Form["session"]) ? UrlHelperExtensions.GetSession(request.Form["session"]) : request.Params["session"]; customer_account user = api.LoadFromAccessToken(session).Data; string identifier = request.Params["exchange_option_identifier"] == null ? string.Empty : request.Params["exchange_option_identifier"]; string transactionId = request.Params["transaction_id"]; ErrorCodes? error = null; if (game == null) error = ErrorCodes.INVALID_GAME_ID; else if (user == null) error = ErrorCodes.INVALID_SESSION; else { RBAC rbac = new RBAC(user.id); bool? isActive = true; //# To allow admin account to test exchange option without showing it to everyone if (rbac.HasRole(GoPlayConstantValues.S_ROLE_GAME_ADMIN) || rbac.HasRole(GoPlayConstantValues.S_ROLE_ADMIN)) isActive = null; Tuple<string, int> tuple = api.GetExchangeOption(identifier, isActive, false); if (tuple == null) error = ErrorCodes.INVALID_EXCHANGE_OPTION; else { var lstExternalExchange = api.GetExternalExchanges(user.id, game.id, null, transactionId); if (lstExternalExchange != null && lstExternalExchange.Any()) error = ErrorCodes.EXCHANGE_RECORDED; else { var externalExchange = new external_exchange { customer_account_id = user.id, game_id = game.id, exchange_option_identifier = identifier, transaction_id = transactionId }; if (string.Compare(tuple.Item1, GoPlayConstantValues.S_CREDIT_TYPE, StringComparison.OrdinalIgnoreCase) == 0) externalExchange.credit_type_id = tuple.Item2; else if (string.Compare(tuple.Item1, GoPlayConstantValues.S_PACKAGE, StringComparison.OrdinalIgnoreCase) == 0) externalExchange.package_id = tuple.Item2; if (!api.CreateExternalExchange(externalExchange)) error = ErrorCodes.ServerError; } } } api.LogApi("1", request.Url.LocalPath, error == null, request.UserAgent != null ? request.UserAgent.ToString() : string.Empty, game == null ? 0 : game.id, user == null ? 0 : user.id, request.UserHostAddress, error.ToErrorCode(), request.Params.ToString()); if (error == null) return Json(new { success = true }); return Json(new { success = false, message = error.ToErrorMessage(), error_code = error.ToErrorCode() }); }