Ejemplo n.º 1
0
        public Task GameSettingInfo([FromForm] int?id)
        {
            GameSetting setting = id == null ? new GameSetting():
                                  (GameSettingAgent.Instance().GetGameSettingInfo(id.Value) ?? new GameSetting());

            return(this.GetResult(setting));
        }
Ejemplo n.º 2
0
        public Task SaveSetting([FromForm] int id, [FromForm] GameType?type, [FromForm] string code, [FromForm] string name,
                                [FromForm] string setting, [FromForm] string remark)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(this.ShowError("请输入游戏名称"));
            }
            if (type == null)
            {
                return(this.ShowError("请输入游戏类型"));
            }

            GameSetting gamesetting = new GameSetting()
            {
                ID            = id,
                Type          = type.Value,
                Code          = code,
                Name          = name,
                Status        = GameStatus.Open,
                MaintainTime  = DateTime.MinValue,
                SettingString = setting,
                Remark        = remark
            };

            return(this.GetResult(GameSettingAgent.Instance().SaveSetting(gamesetting)));
        }
Ejemplo n.º 3
0
        public Task UpdateIsOpen([FromForm] int id, [FromForm] bool isOpen)
        {
            var setting = GameSettingAgent.Instance().GetGameSettingInfo(id);

            if (setting == null)
            {
                return(this.ShowError("记录不存在"));
            }
            setting.IsOpen = isOpen;

            return(this.GetResult(GameSettingAgent.Instance().UpdateIsOpen(setting)));
        }
Ejemplo n.º 4
0
        public Task GameSettingInfo([FromForm] int?id)
        {
            GameSetting setting = id == null ? new GameSetting():
                                  (GameSettingAgent.Instance().GetGameSettingInfo(id.Value) ?? new GameSetting());

            IGameProvider iProvider = GameFactory.GetFactory(setting.Type.ToString(), setting.SettingString);

            return(this.GetResult(new
            {
                setting.ID,
                setting.Name,
                setting.Code,
                setting.Type,
                setting.Status,
                setting.MaintainTime,
                setting.Remark,
                Setting = setting.ID == 0 ? new JsonString("[]") : new JsonString(iProvider.ToSetting())
            }));
        }
Ejemplo n.º 5
0
        public Task SaveSetting([FromForm] int id, [FromForm] int providerId, [FromForm] string name, [FromForm] string type, [FromForm] string category, [FromForm] bool isOpen)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(this.ShowError("请输入游戏名称"));
            }
            if (string.IsNullOrWhiteSpace(type))
            {
                return(this.ShowError("请输入游戏类型"));
            }
            if (string.IsNullOrWhiteSpace(category))
            {
                return(this.ShowError("至少选择游戏分类"));
            }
            if (providerId <= 0)
            {
                return(this.ShowError("请选择供应商"));
            }

            //分类集合
            var cate        = (GameCategory)0;
            var arrCategory = category.Split(',');

            foreach (string item in arrCategory)
            {
                cate = cate | item.ToEnum <GameCategory>();
            }

            GameSetting setting = new GameSetting()
            {
                ID         = id,
                Name       = name,
                Type       = type,
                Category   = cate,
                IsOpen     = isOpen,
                ProviderID = providerId,
                Sort       = 0
            };

            return(this.GetResult(GameSettingAgent.Instance().SaveSetting(setting)));
        }
Ejemplo n.º 6
0
        public Task UpdateStatus([FromForm] int id, [FromForm] GameStatus status, [FromForm] DateTime maintainTime)
        {
            var setting = GameSettingAgent.Instance().GetGameSettingInfo(id);

            if (setting == null)
            {
                return(this.ShowError("记录不存在"));
            }
            setting.Status = status;

            if (status == GameStatus.Maintain)
            {
                setting.MaintainTime = maintainTime;
            }
            else
            {
                setting.MaintainTime = DateTime.MinValue;
            }

            return(this.GetResult(GameSettingAgent.Instance().UpdateStatus(setting)));
        }
Ejemplo n.º 7
0
 public Task GameSettingDelete([FromForm] int id)
 {
     return(this.GetResult(GameSettingAgent.Instance().DeleteGameSettingInfo(id)));
 }