public Result<Package> RetrieveExchangeHandler(customer_account user, Game game, decimal amount, CreditType creditType = null, GoPlay.Models.Package package = null) { // var exchangeHandlers = { // '8b1d8776e813536ecfy': MineManiaExchangeHandler, // 'ob5d4579e123381ecfy': SushiZombieExchangeHandler, // '853461dsfwdgf85m0op': SlamdunkExchangeHandler, // 'c4c8d825a0ee6a78': FishingHeroExchangeHandler // return exchangeHandlers.get(game.guid, StandardExchangeHandler)(user, game, exchangeOption, amount) //} return null; }
public int CreateCreditType(CreditType creditType) { var repo = Repo.Instance; using (var db = repo.OpenConnectionFromPool()) { return repo.CreateCreditType(db, creditType); } }
public ActionResult CreditTypeAdd(AdminEditExchangeModel model) { if (ModelState.IsValid) { var game = GameHelper.GetGameForCurrentUser(CurrentUser, model.game_id); var api = GoPlayApi.Instance; if (!PermissionHelper.HasManageStudio(CurrentUser.GetRoles(), CurrentUser.Id, game.studio_id ?? 0)) { return new HttpStatusCodeResult(403); } if (api.GetCreditType(model.string_identifier).Data != null) { ModelState.AddModelError("string_identifier", Resources.Resources.STRING_IDENTIFIER_DUPLICATE); return View("Edit", model); } CreditType creditType = new CreditType(); creditType = EditCreditType(creditType, model); int newId = api.CreateCreditType(creditType); if (newId > 0) { this.Flash(string.Format("Successfully added credit type {0}!", model.name), FlashLevel.Success); return RedirectToAction("CreditTypeDetail", "exchange", new { id = newId }); } this.Flash(string.Format(ErrorCodes.ServerError.ToErrorMessage(), model.name), FlashLevel.Error); return View("Edit", model); } return View("Edit", model); }
private CreditType EditCreditType(CreditType creditType, AdminEditExchangeModel model) { if (model.icon != null && model.icon.ContentLength > 0) { string path = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["UPLOADS_DIR"]); string filename = GoPlayApi.Instance.HandleFile(HttpContext.Server.MapPath("~"), model.icon.InputStream, path, model.icon.FileName); creditType.icon_filename = filename; } creditType.is_active = (!String.IsNullOrEmpty(model.is_active) && model.is_active == "on") ? true : false; creditType.is_archived = (!string.IsNullOrEmpty(model.is_archived) && model.is_archived == "on") ? true : false; creditType.updated_at = DateTime.UtcNow; creditType.exchange_rate = model.exchange_rate; creditType.free_exchange_rate = model.free_exchange_rate; creditType.game_id = model.game_id; creditType.name = model.name; creditType.string_identifier = model.string_identifier; return creditType; }
public int CreateCreditType(IDbConnection db, CreditType creditType) { string stringSql = @"INSERT INTO credit_type (game_id, name, exchange_rate, icon_filename, created_at, updated_at, is_archived, old_db_id, free_exchange_rate, is_active, string_identifier) VALUES (@game_id, @name, @exchange_rate, @icon_filename, @created_at, @updated_at, @is_archived, @old_db_id, @free_exchange_rate, @is_active, @string_identifier) RETURNING id"; return db.Query<int>(stringSql, creditType).FirstOrDefault(); }
public bool UpdateCreditType(IDbConnection db, CreditType creditType) { string stringSql = @"UPDATE credit_type SET game_id = @game_id, name = @name, exchange_rate = @exchange_rate, icon_filename = @icon_filename, created_at = @created_at, updated_at = @updated_at, is_archived = @is_archived, old_db_id = @old_db_id, free_exchange_rate = @free_exchange_rate, is_active = @is_active, string_identifier = @string_identifier WHERE id = @id"; return 1 == db.Execute(stringSql, creditType); }