public object EnFreeRule(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; string state = dicParas.ContainsKey("state") ? (dicParas["state"] + "") : string.Empty; if (string.IsNullOrEmpty(id)) { errMsg = "送局规则ID不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(state)) { errMsg = "启用状态state不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } int iState = Convert.ToInt32(state); int iId = Convert.ToInt32(id); IData_GameFreeRuleService data_GameFreeRuleService = BLLContainer.Resolve <IData_GameFreeRuleService>(); if (!data_GameFreeRuleService.Any(a => a.ID == iId)) { errMsg = "该送局规则信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var data_GameFreeRule = data_GameFreeRuleService.GetModels(p => p.ID == iId).FirstOrDefault(); data_GameFreeRule.State = iState; if (!data_GameFreeRuleService.Update(data_GameFreeRule)) { errMsg = "更新送局规则信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }
public object DelFreeRule(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; if (string.IsNullOrEmpty(id)) { errMsg = "送局规则ID不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } int iId = Convert.ToInt32(id); IData_GameFreeRuleService data_GameFreeRuleService = BLLContainer.Resolve <IData_GameFreeRuleService>(); IData_GameFreeRule_ListService data_GameFreeRule_ListService = BLLContainer.Resolve <IData_GameFreeRule_ListService>(); IFlw_Game_FreeService flw_Game_FreeService = BLLContainer.Resolve <IFlw_Game_FreeService>(); if (flw_Game_FreeService.Any(a => a.RuleID == iId)) { errMsg = "该送局规则已使用不能删除"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!data_GameFreeRuleService.Any(a => a.ID == iId)) { errMsg = "该送局规则信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } //开启EF事务 using (TransactionScope ts = new TransactionScope()) { try { var data_GameFreeRule = data_GameFreeRuleService.GetModels(p => p.ID == iId).FirstOrDefault(); data_GameFreeRuleService.DeleteModel(data_GameFreeRule); var data_GameFreeRule_List = data_GameFreeRule_ListService.GetModels(p => p.RuleID == iId); foreach (var data_GameFreeRule_ListMode in data_GameFreeRule_List) { data_GameFreeRule_ListService.DeleteModel(data_GameFreeRule_ListMode); } if (!data_GameFreeRuleService.SaveChanges()) { errMsg = "删除送局规则信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } ts.Complete(); } catch (Exception ex) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, ex.Message)); } } return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }