/// <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> /// 添加蓄电池/加油卡浮动配置 /// </summary> /// <param name="request"></param> /// <returns></returns> public BaoYangResultEntity <bool> InsertCouponActivityConfig(CouponActivityConfigV2Model request, string name) { var result = new BaoYangResultEntity <bool>() { Status = false }; try { dbScopeManagerConfiguration.CreateTransaction(conn => { request.ActivityNum = Guid.NewGuid().ToString(); var configId = DalCouponActivityConfigV2.InsertCouponActivityConfig(conn, request); if (configId > 0) { if (request.ChannelConfigs != null && request.ChannelConfigs.Any()) { foreach (var item in request.ChannelConfigs) { item.ConfigId = configId; DalCouponActivityConfigV2.InsertChannelConfigsById(conn, item); } } result.Status = true; result.Data = true; request.Id = configId; } else { result.Data = false; } }); if (result.Status) { SaveCouponActivityConfigLog(null, request, name); } } catch (Exception ex) { result.Status = false; result.Msg = "程序遇见错误,请联系管理员"; Logger.Error("GetCouponActivityConfigs", ex); } return(result); }