|
|
|
@ -154,10 +154,36 @@ namespace Myshipping.Core.Service
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
await _repContact.DeleteAsync(x => x.CustomerId == input.Id);
|
|
|
|
|
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
|
|
|
|
|
contactList.ForEach(x => x.CustomerId = entity.Id);
|
|
|
|
|
await _repContact.InsertAsync(contactList);
|
|
|
|
|
|
|
|
|
|
//await _repContact.DeleteAsync(x => x.CustomerId == input.Id);
|
|
|
|
|
//var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
|
|
|
|
|
//contactList.ForEach(x => x.CustomerId = entity.Id);
|
|
|
|
|
//await _repContact.InsertAsync(contactList);
|
|
|
|
|
|
|
|
|
|
var dbContact = await _repContact.AsQueryable().Where(x => x.CustomerId == input.Id).ToListAsync();
|
|
|
|
|
foreach (var dtoUser in input.Contacts)
|
|
|
|
|
{
|
|
|
|
|
if (dtoUser.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
var contact = dbContact.First(x => x.Id == dtoUser.Id);
|
|
|
|
|
dtoUser.Adapt(contact);
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _repContact.UpdateAsync(contact);
|
|
|
|
|
dbContact.Remove(contact);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var contact = dtoUser.Adapt<DjyCustomerContact>();
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _repContact.InsertAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var contact in dbContact)
|
|
|
|
|
{
|
|
|
|
|
await _repContact.DeleteAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//地址
|
|
|
|
|
await _repAddr.DeleteAsync(x => x.CustomerId == input.Id);
|
|
|
|
|
var addrList = input.Addrs.Adapt<List<DjyCustomerAddr>>();
|
|
|
|
|