Exemplo n.º 1
0
        public object DelGameInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string id     = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty;
                if (string.IsNullOrEmpty(id))
                {
                    errMsg = "游戏机流水号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int iId = Convert.ToInt32(id);
                IData_GameInfoService data_GameInfoService = BLLContainer.Resolve <IData_GameInfoService>();
                if (!data_GameInfoService.Any(a => a.ID == iId))
                {
                    errMsg = "该游戏机信息不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                var data_GameInfo = data_GameInfoService.GetModels(p => p.ID == iId).FirstOrDefault();
                if (!data_GameInfoService.Delete(data_GameInfo))
                {
                    errMsg = "删除游戏机信息失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Exemplo n.º 2
0
        public object GetGameInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string id     = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty;
                if (string.IsNullOrEmpty(id))
                {
                    errMsg = "游戏机流水号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int iId = Convert.ToInt32(id);

                IData_GameInfoService data_GameInfoService = BLLContainer.Resolve <IData_GameInfoService>(resolveNew: true);
                if (!data_GameInfoService.Any(a => a.ID == iId))
                {
                    errMsg = "该游戏机信息不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IDict_SystemService dict_SystemService = BLLContainer.Resolve <IDict_SystemService>(resolveNew: true);
                int GameInfoId = dict_SystemService.GetModels(p => p.DictKey.Equals("游戏机档案维护")).FirstOrDefault().ID;
                var result     = from a in data_GameInfoService.GetModels(p => p.ID == iId).FirstOrDefault().AsDictionary()
                                 join b in dict_SystemService.GetModels(p => p.PID == GameInfoId) on a.Key equals b.DictKey into b1
                                 from b in b1.DefaultIfEmpty()
                                 select new {
                    name    = a.Key,
                    value   = a.Value,
                    comment = b != null ? b.Comment : string.Empty
                };

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, result));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Exemplo n.º 3
0
        public object SaveGameInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID;

                string errMsg   = string.Empty;
                string gameId   = dicParas.ContainsKey("GameID") ? (dicParas["GameID"] + "") : string.Empty;
                string id       = dicParas.ContainsKey("ID") ? (dicParas["ID"] + "") : string.Empty;
                string gameName = dicParas.ContainsKey("GameName") ? (dicParas["GameName"] + "") : string.Empty;

                if (string.IsNullOrEmpty(gameId))
                {
                    errMsg = "游戏机编号GameID不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (gameId.Length > 4)
                {
                    errMsg = "游戏机编号GameID不能超过4个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (string.IsNullOrEmpty(gameName))
                {
                    errMsg = "游戏机名称GameName不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (!string.IsNullOrEmpty(id) && !Utils.isNumber(id))
                {
                    errMsg = "游戏机参数ID格式不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IData_GameInfoService data_GameInfoService = BLLContainer.Resolve <IData_GameInfoService>();
                var data_GameInfo = new Data_GameInfo();
                if (string.IsNullOrEmpty(id))
                {
                    if (data_GameInfoService.Any(a => a.GameID.Equals(gameId, StringComparison.OrdinalIgnoreCase)))
                    {
                        errMsg = "该游戏机编号已使用";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    Utils.GetModel(dicParas, ref data_GameInfo);
                    data_GameInfo.StoreID = storeId;
                    if (!data_GameInfoService.Add(data_GameInfo))
                    {
                        errMsg = "新增游戏机信息失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }
                else
                {
                    int iId = Convert.ToInt32(id);
                    if (!data_GameInfoService.Any(a => a.ID == iId))
                    {
                        errMsg = "该游戏机不存在";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                    if (data_GameInfoService.Any(a => a.ID != iId && a.GameID.Equals(gameId, StringComparison.OrdinalIgnoreCase)))
                    {
                        errMsg = "该游戏机编号已使用";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    data_GameInfo = data_GameInfoService.GetModels(p => p.ID == iId).FirstOrDefault();
                    Utils.GetModel(dicParas, ref data_GameInfo);
                    data_GameInfo.StoreID = storeId;
                    if (!data_GameInfoService.Update(data_GameInfo))
                    {
                        errMsg = "修改游戏机信息失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (DbEntityValidationException e)
            {
                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, e.EntityValidationErrors.ToErrors()));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }