using Yw.DAL.PostgreSql;
|
|
namespace HStation.DAL.PostgreSql
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class AssetsCompressorPartMain : BaseDAL_Sorter<Entity.AssetsCompressorPartMain>, IAssetsCompressorPartMain
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; }
|
}
|
|
//插入拓展
|
public long InsertsEx(Entity.AssetsCompressorPartMain part, List<Entity.AssetsCompressorPropContent> AssetsCompressorPropContents, Entity.AssetsCompressorMainAndPartMap partmap)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Insertable(part).ExecuteReturnSnowflakeId();
|
if (result < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (partmap != null)
|
{
|
partmap.PartID = result;
|
var mainandpartmap = db.Insertable(partmap).ExecuteReturnSnowflakeId();
|
if (mainandpartmap < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsCompressorPropContents != null)
|
{
|
foreach (var item in AssetsCompressorPropContents)
|
{
|
item.PartID = result;
|
}
|
var content = db.Insertable(AssetsCompressorPropContents).ExecuteReturnSnowflakeId();
|
if (content < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
}
|
}
|
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
//编辑拓展
|
public bool UpdateEx(Entity.AssetsCompressorPartMain part, List<Entity.AssetsCompressorPropContent> AssetsCompressorPropContents)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Updateable(part).ExecuteCommandHasChange();
|
if (!result)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsCompressorPropContents != null)
|
{
|
var propresult = db.Updateable(AssetsCompressorPropContents).ExecuteCommandHasChange();
|
if (!propresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
//删除拓展 (删除产品表及属性表)
|
public bool DeleteEx(Entity.AssetsCompressorPartMain part, List<Entity.AssetsCompressorPropContent> AssetsCompressorPropContents)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Deleteable(part).ExecuteCommand() > 0;
|
if (!result)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsCompressorPropContents != null)
|
{
|
var propresult = db.Deleteable(AssetsCompressorPropContents).ExecuteCommand() > 0;
|
if (!propresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
}
|
}
|