修改订舱的保存方法,解决保存是箱下多品名为空和EDI扩展信息为空的情况

booking_auth_dev
jianghaiqing 2 years ago
parent e26f75620f
commit 9fbad0fcb7

@ -333,21 +333,29 @@ namespace Myshipping.Application
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
foreach (var it in item.ctnDetailInputs)
//这里保存有可能没有添加多品名,所有箱下没有货物信息
if (item.ctnDetailInputs != null)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
//写入EDI扩展
var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
if (input.BookingEDIExt != null)
{
//写入EDI扩展
var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity);
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
////添加booking日志
await _bookinglog.InsertAsync(new BookingLog
@ -444,27 +452,30 @@ namespace Myshipping.Application
}
}
//检索EDI扩展
var ediExtEntity = await _bookingEDIExt.FirstOrDefaultAsync(u => u.BookingId == input.Id);
if(ediExtEntity == null)
if (input.BookingEDIExt != null)
{
//写入EDI扩展
ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
//检索EDI扩展
var ediExtEntity = await _bookingEDIExt.FirstOrDefaultAsync(u => u.BookingId == input.Id);
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
else
{
//更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
if (ediExtEntity == null)
{
//写入EDI扩展
ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
else
{
//更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.BookingId = ediExtEntity.BookingId;
currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.BookingId = ediExtEntity.BookingId;
await _bookingEDIExt.AsUpdateable(ediExtEntity).IgnoreColumns(new string[] { nameof(ediExtEntity.Id),
await _bookingEDIExt.AsUpdateable(ediExtEntity).IgnoreColumns(new string[] { nameof(ediExtEntity.Id),
nameof(ediExtEntity.BookingId) }).ExecuteCommandAsync();
}
}

Loading…
Cancel
Save