Пример #1
0
        public async Task <IActionResult> CreateStone(uint id, string body)
        {
            var  menu = JsonConvert.DeserializeObject <StoneMenu>(body);
            uint db   = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                await conn.ExecuteAsync(
                    "INSERT INTO `pomelo_teleport_template` " +
                    "(`menu_id`, `action_id`, `icon`, `menu_item_text`, " +
                    "`teleport_x`, `teleport_y`, `teleport_z`, `teleport_map`, " +
                    "`function`, `cost_type`, `cost_amount`, " +
                    "`cost_custom_currency_id`, `level_required`, " +
                    "`permission_required`, `trigger_menu`, `faction_order`) " +
                    "VALUES (@MenuId, @ActionId, @Icon, @MenuItemText," +
                    "@TeleportX, @TeleportY, @TeleportZ, @TeleportMap, " +
                    "@Function, @CostType, @CostAmount, @CostCurrencyId," +
                    "@LevelRequired, @PermissionRequired, @TriggerMenu," +
                    "@FactionOrder);", menu);

                return(Prompt(x =>
                {
                    x.Title = "创建成功";
                    x.Details = "新的菜单项已经创建";
                    x.RedirectText = "返回菜单列表";
                    x.RedirectUrl = Url.Action("Stone", new { id });
                }));
            }
        }
Пример #2
0
        public async Task <IActionResult> EditStone(uint menuId, uint actionId)
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var menu = (await conn.QueryAsync <StoneMenu>(
                                "SELECT * FROM `pomelo_teleport_template` " +
                                "WHERE `menu_id` = @menuId AND `action_id` = @actionId;",
                                new { menuId, actionId })).SingleOrDefault();
                if (menu == null)
                {
                    return(Prompt(x =>
                    {
                        x.Title = "没有找到菜单";
                        x.Details = "您指定的宝石菜单没有找到,请返回重试";
                        x.StatusCode = 404;
                    }));
                }

                using (var conn2 = CustomCurrency.GetAuthDb())
                {
                    var currencies = await conn2.QueryAsync <CustomCurrency>(
                        "SELECT * FROM `pomelo_currency`;");

                    ViewBag.Currencies = currencies;
                }

                return(View(menu));
            }
        }
Пример #3
0
        public async Task <IActionResult> Dungeon()
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var dungeons = (await conn.QueryAsync <DungeonSwitch>(
                                    "SELECT * FROM `pomelo_dungeon_switch`;")).ToList();
                return(View(dungeons));
            }
        }
Пример #4
0
        private async Task <uint?> FindParentMenuAsync(uint menuId)
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var id = (await conn.QueryAsync <uint?>(
                              "SELECT `menu_id` " +
                              "FROM `pomelo_teleport_template` " +
                              "WHERE `trigger_menu` = @menuId;",
                              new { menuId })).FirstOrDefault();
                return(id);
            }
        }
Пример #5
0
        public async Task <IActionResult> Stone(uint id = 0)
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var menu = (await conn.QueryAsync <StoneMenu>(
                                "SELECT * FROM `pomelo_teleport_template` " +
                                "WHERE `menu_id` = @id;", new { id })).ToList();
                if (id != 0)
                {
                    ViewBag.Prev = await FindParentMenuAsync(id);
                }
                return(View(menu));
            }
        }
Пример #6
0
        public async Task <IActionResult> Dungeon(uint id, bool status)
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                await conn.ExecuteAsync(
                    "UPDATE `pomelo_dungeon_switch` " +
                    $"SET `disabled` = {(status ? "TRUE" : "FALSE")} " +
                    "WHERE `entry` = @id;", new { id });

                return(Prompt(x =>
                {
                    x.Title = $"{(status ? "禁用" : "开启")}副本成功";
                    x.Details = "已更新副本开关状态";
                }));
            }
        }
Пример #7
0
        public async Task <IActionResult> EditStone(uint id, string body)
        {
            var menu = JsonConvert.DeserializeObject <StoneMenu>(body);

            menu.Id = id;
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var origin = (await conn.QueryAsync <StoneMenu>(
                                  "SELECT * FROM `pomelo_teleport_template` " +
                                  "WHERE `entry` = @id;",
                                  new { id })).SingleOrDefault();

                var modifyId = "`menu_id` = @MenuId, `action_id` = @ActionId, ";
                if (origin.MenuId == menu.MenuId && origin.ActionId == menu.ActionId)
                {
                    modifyId = "";
                }

                await conn.ExecuteAsync(
                    "UPDATE `pomelo_teleport_template` " +
                    "SET `menu_item_text` = @MenuItemText, `icon` = @Icon, " +
                    modifyId +
                    "`function` = @Function, `teleport_map` = @TeleportMap, " +
                    "`teleport_x` = @TeleportX, `teleport_y` = @TeleportY, " +
                    "`teleport_z` = @TeleportZ, `cost_type` = @CostType, " +
                    "`cost_amount` = @CostAmount, `cost_custom_currency_id` = @CostCurrencyId, " +
                    "`level_required` = @LevelRequired, `permission_required` = @PermissionRequired, " +
                    "`trigger_menu` = @TriggerMenu, `faction_order` = @FactionOrder " +
                    "WHERE `entry` = @Id; ", menu);

                return(Prompt(x =>
                {
                    x.Title = "编辑成功";
                    x.Details = "菜单已经成功保存";
                    x.RedirectText = "返回上级菜单";
                    x.RedirectUrl = Url.Action("Stone", new { id = menu.MenuId });
                }));
            }
        }
Пример #8
0
        public async Task <IActionResult> RemoveStone(uint id)
        {
            uint db = (uint)HttpContext.Session.GetInt32("world");

            using (var conn = StoneMenu.GetWorldDb(db))
            {
                var menuId = (await conn.QueryAsync <uint?>(
                                  "SELECT `menu_id` FROM `pomelo_teleport_template` " +
                                  "WHERE `entry` = @id;", new { id })).FirstOrDefault();

                if (!menuId.HasValue)
                {
                    return(Prompt(x =>
                    {
                        x.Title = "删除失败";
                        x.Details = "您指定的菜单项没有找到";
                        x.StatusCode = 404;
                    }));
                }

                await conn.ExecuteAsync(
                    "DELETE FROM `pomelo_teleport_template` " +
                    "WHERE `entry` = @id;", new { id });

                var cnt = (await conn.QueryAsync <int>(
                               "SELECT COUNT(1) FROM `pomelo_teleport_template` " +
                               "WHERE `menu_id` = @menuId", new { menuId = menuId.Value })).Single();

                uint?parentId = await FindParentMenuAsync(menuId.Value);

                return(Prompt(x =>
                {
                    x.Title = "删除成功";
                    x.Details = "该菜单项已被成功删除";
                    x.RedirectText = cnt == 0 ? "返回上级菜单" : "返回菜单列表";
                    x.RedirectUrl = cnt == 0 ? Url.Action("Stone", new { id = parentId }) : Url.Action("Stone", new { id = menuId });
                }));
            }
        }