Exemplo n.º 1
0
        public bool UpdatePackage(IDbConnection db, Package package)
        {
            string stringSql = @"UPDATE package
				SET 
                    game_id = @game_id,
                    name = @name,
                    play_token_value = @play_token_value,
                    icon_filename = @icon_filename,
                    created_at = @created_at,
                    updated_at = @updated_at,
                    is_archived = @is_archived,
                    old_db_id = @old_db_id,
                    free_play_token_value = @free_play_token_value,
                    is_active = @is_active,
                    string_identifier = @string_identifier,
                    limited_time_offer = @limited_time_offer

				WHERE id = @id";
            return 1 == db.Execute(stringSql, package);
        }
Exemplo n.º 2
0
        public int CreatePackage(IDbConnection db, Package package)
        {
            string stringSql = @"INSERT INTO package(
                game_id, name, play_token_value, icon_filename, created_at, 
                updated_at, is_archived, old_db_id, free_play_token_value, is_active, 
                string_identifier, limited_time_offer)
            VALUES(
                @game_id, @name, @play_token_value, @icon_filename, @created_at, 
                @updated_at, @is_archived, @old_db_id, @free_play_token_value, @is_active, 
                @string_identifier, @limited_time_offer)
            RETURNING id";

            return db.Query<int>(stringSql, package).FirstOrDefault();
        }
Exemplo n.º 3
0
        private Package EditPackage(Package package, 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);
                package.icon_filename = filename;
            }

            package.is_active = (!string.IsNullOrEmpty(model.is_active) && model.is_active == "on")
                ? true
                : false;
            package.is_archived = (!string.IsNullOrEmpty(model.is_archived) && model.is_archived == "on")
                ? true
                : false;
            package.updated_at = DateTime.UtcNow;
            package.play_token_value = model.play_token_value;
            package.free_play_token_value = model.free_play_token_value;
            package.game_id = model.game_id;
            package.name = model.name;
            package.string_identifier = model.string_identifier;
            package.limited_time_offer = model.limited_time_offer;

            return package;
        }
Exemplo n.º 4
0
 public bool UpdatePackage(Package package)
 {
     var repo = Repo.Instance;
     using (var db = repo.OpenConnectionFromPool())
     {
         return repo.UpdatePackage(db, package);
     }
 }
Exemplo n.º 5
0
        public ActionResult PackageAdd(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);
                }

                Package package = new Package();
                package = EditPackage(package, model);
                int newId = api.CreatePackage(package);
                if (newId > 0)
                {
                    this.Flash(string.Format("Successfully added Package {0}!", model.name), FlashLevel.Success);
                    return RedirectToAction("PackageDetail", "exchange", new { id = newId });
                }

                this.Flash(string.Format(ErrorCodes.ServerError.ToErrorMessage(), model.name), FlashLevel.Error);
                return View("Edit", model);
            }
            return View("Edit", model);
        }