/// <summary> /// 保存时检查 /// </summary> /// <param name="model"></param> /// <returns></returns> public BaoYangResultEntity <bool> SaveCheckBatteryLevelUp(BatteryLevelUpEntity model) { var result = new BaoYangResultEntity <bool>() { Status = true }; try { result = dbScopeManagerBaoYangRead.Execute(conn => { var entity = DALBatteryLevelUp.GetBatteryLevelUpEntityByOriginalPid(conn, model.OriginalPID); //重复原始ID 查询 if (entity != null && entity.PKID != model.PKID) { result.Status = false; result.Msg = "该原始产品已经配置了升级购"; return(result); } entity = DALBatteryLevelUp.GetBatteryLevelUpEntityByNewPID(conn, model.NewPID); if (entity != null && entity.PKID != model.PKID) { result.Status = false; result.Msg = "该升级产品已经配置了升级购"; return(result); } entity = DALBatteryLevelUp.GetBatteryLevelUpEntity(conn, model.OriginalPID, model.NewPID); if (entity != null) { result.Status = false; result.Msg = "升级链不能循环升级"; return(result); } return(result); }); } catch (Exception ex) { Logger.Error(ex.Message, ex); result = new BaoYangResultEntity <bool>() { Status = false, Msg = "修改失败" }; } return(result); }
/// <summary> /// 获取单个实体 /// </summary> /// <param name="pkid"></param> /// <returns></returns> public BaoYangResultEntity <BatteryLevelUpEntity> GetBatteryLevelUpEntity(int pkid) { var result = new BaoYangResultEntity <BatteryLevelUpEntity>(); try { result = dbScopeManagerBaoYangRead.Execute(conn => { return(new BaoYangResultEntity <BatteryLevelUpEntity> { Status = true, Data = DALBatteryLevelUp.GetBatteryLevelUpEntity(conn, pkid) }); }); } catch (Exception ex) { Logger.Error(ex.Message, ex); result = new BaoYangResultEntity <BatteryLevelUpEntity>() { Status = false, Msg = "获取失败" }; } return(result); }