This commit is contained in:
@@ -164,8 +164,6 @@ namespace AyaNova.Biz
|
|||||||
//DELETE DIRECT CHILD OBJECTS
|
//DELETE DIRECT CHILD OBJECTS
|
||||||
//(note: the convention is to allow deletion of children created *in* the same UI area so this will delete contacts, customer notes, but not workorders of this customer for example)
|
//(note: the convention is to allow deletion of children created *in* the same UI area so this will delete contacts, customer notes, but not workorders of this customer for example)
|
||||||
|
|
||||||
//Will need to possibly display refintegrity error from the *linked* object delete attemp, i.e. Contact for here
|
|
||||||
//so should test that out so that it flows to the UI so user understands they can't delete the Customer due to a Contact having links to other objects
|
|
||||||
{
|
{
|
||||||
var ContactIds = await ct.User.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
var ContactIds = await ct.User.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
||||||
if (ContactIds.Count() > 0)
|
if (ContactIds.Count() > 0)
|
||||||
@@ -174,7 +172,7 @@ namespace AyaNova.Biz
|
|||||||
foreach (long ItemId in ContactIds)
|
foreach (long ItemId in ContactIds)
|
||||||
if (!await b.DeleteAsync(ItemId, transaction))
|
if (!await b.DeleteAsync(ItemId, transaction))
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, b.GetErrorsAsString());
|
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerContact [{ItemId}]: {b.GetErrorsAsString()}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +185,7 @@ namespace AyaNova.Biz
|
|||||||
foreach (long ItemId in CustomerNoteIds)
|
foreach (long ItemId in CustomerNoteIds)
|
||||||
if (!await b.DeleteAsync(ItemId, transaction))
|
if (!await b.DeleteAsync(ItemId, transaction))
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, b.GetErrorsAsString());
|
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerNote [{ItemId}]: {b.GetErrorsAsString()}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user