/// <summary> /// 修改蓄电池/加油卡浮动配置 /// </summary> /// <param name="request"></param> /// <returns></returns> public BaoYangResultEntity <bool> UpdateCouponActivityConfig(CouponActivityConfigV2Model configModel, string name) { var result = new BaoYangResultEntity <bool>() { Status = false }; try { var oldModel = GetCouponActivityConfig(configModel.Id).Data; dbScopeManagerConfiguration.CreateTransaction(conn => { if (DalCouponActivityConfigV2.UpdateCouponActivityConfig(conn, configModel)) { if (configModel.ChannelConfigs != null && configModel.ChannelConfigs.Any()) { var configIds = new List <int> { configModel.Id }; DalCouponActivityConfigV2.DeleteChannelConfigsByConfigId(conn, configIds); foreach (var item in configModel.ChannelConfigs) { DalCouponActivityConfigV2.InsertChannelConfigsById(conn, item); } result.Status = true; result.Data = true; } else { result.Status = true; result.Data = true; } } else { result.Data = false; } }); if (result.Status) { SaveCouponActivityConfigLog(oldModel, configModel, name); } } catch (Exception ex) { result.Status = false; result.Msg = "程序遇见错误,请联系管理员"; Logger.Error("GetCouponActivityConfigs", ex); } return(result); }
/// <summary> /// 根据ID 删除单个模型 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <BaoYangResultEntity <bool> > DeleteChannelConfigsByConfigId(int id, string name) { var result = new BaoYangResultEntity <bool>() { Status = false }; try { var oldModel = GetCouponActivityConfig(id).Data; await RemoveCouponActivityConfigCache(id); dbScopeManagerConfiguration.CreateTransaction(conn => { if (DalCouponActivityConfigV2.DeleteCouponActivityConfig(conn, id)) { var configIds = new List <int> { id }; result.Data = DalCouponActivityConfigV2.DeleteChannelConfigsByConfigId(conn, configIds); result.Status = true; result.Data = true; } else { result.Data = false; } }); if (result.Status && oldModel != null) { SaveCouponActivityConfigLog(oldModel, null, name); } } catch (Exception ex) { result.Status = false; result.Msg = "程序遇见错误,请联系管理员"; Logger.Error("GetCouponActivityConfigs", ex); } return(result); }