Removed superfluous try catch throw pattern
This commit is contained in:
@@ -224,35 +224,26 @@ MULTIPLE discount / markup ITEMS
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Contract dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Contract dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Contract.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Contract.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -353,7 +344,7 @@ MULTIPLE discount / markup ITEMS
|
||||
//SERVICE RATES
|
||||
if (proposedObj.ContractServiceRateOverrideItems.Count > 0)
|
||||
{
|
||||
// List<string> allTags = new List<string>();
|
||||
// List<string> allTags = new List<string>();
|
||||
//check for overlapping dupes
|
||||
//[NO DON"T CHECK FOR DUPES, OR AT LEAST NOT LIKE THIS, REMOVING FOR NOW]
|
||||
//Not sure what the dupe intent was but it should be entirely duped, not just one tag in common as with this
|
||||
@@ -389,7 +380,7 @@ MULTIPLE discount / markup ITEMS
|
||||
//TRAVEL RATES
|
||||
if (proposedObj.ContractTravelRateOverrideItems.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < proposedObj.ContractTravelRateOverrideItems.Count; i++)
|
||||
for (int i = 0; i < proposedObj.ContractTravelRateOverrideItems.Count; i++)
|
||||
{
|
||||
var item = proposedObj.ContractTravelRateOverrideItems[i];
|
||||
if (item.Tags.Count < 1)
|
||||
@@ -673,7 +664,7 @@ MULTIPLE discount / markup ITEMS
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -152,67 +152,59 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
|
||||
Customer dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Customer dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
|
||||
//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)
|
||||
|
||||
{
|
||||
var ContactIds = await ct.User.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
||||
if (ContactIds.Count() > 0)
|
||||
{
|
||||
UserBiz b = new UserBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in ContactIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerContact [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
var CustomerNoteIds = await ct.CustomerNote.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
||||
if (CustomerNoteIds.Count() > 0)
|
||||
{
|
||||
CustomerNoteBiz b = new CustomerNoteBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in CustomerNoteIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerNote [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ct.Customer.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
|
||||
//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: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way
|
||||
|
||||
|
||||
throw;
|
||||
var ContactIds = await ct.User.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
||||
if (ContactIds.Count() > 0)
|
||||
{
|
||||
UserBiz b = new UserBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in ContactIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerContact [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
var CustomerNoteIds = await ct.CustomerNote.AsNoTracking().Where(z => z.CustomerId == id).Select(z => z.Id).ToListAsync();
|
||||
if (CustomerNoteIds.Count() > 0)
|
||||
{
|
||||
CustomerNoteBiz b = new CustomerNoteBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in CustomerNoteIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"CustomerNote [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ct.Customer.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -377,7 +369,7 @@ namespace AyaNova.Biz
|
||||
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
|
||||
|
||||
|
||||
foreach (Customer w in orderedList)
|
||||
{
|
||||
await PopulateVizFields(w);
|
||||
|
||||
@@ -119,35 +119,29 @@ namespace AyaNova.Biz
|
||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
||||
if (parentTransaction == null)
|
||||
transaction = await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
|
||||
CustomerNote dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
CustomerNote dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.CustomerNote.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.CustomerNote.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, "CustomerNote", ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, "CustomerNote", ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
@@ -147,35 +147,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
CustomerServiceRequest dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
CustomerServiceRequest dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.CustomerServiceRequest.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.CustomerServiceRequest.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,52 +151,43 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
|
||||
//DELETE DIRECT CHILD OBJECTS
|
||||
{
|
||||
var ContactIds = await ct.User.AsNoTracking().Where(z => z.HeadOfficeId == id).Select(z => z.Id).ToListAsync();
|
||||
if (ContactIds.Count() > 0)
|
||||
{
|
||||
UserBiz b = new UserBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in ContactIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"HeadOfficeContact [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ct.HeadOffice.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
|
||||
//DELETE DIRECT CHILD OBJECTS
|
||||
{
|
||||
//NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way
|
||||
|
||||
|
||||
throw;
|
||||
var ContactIds = await ct.User.AsNoTracking().Where(z => z.HeadOfficeId == id).Select(z => z.Id).ToListAsync();
|
||||
if (ContactIds.Count() > 0)
|
||||
{
|
||||
UserBiz b = new UserBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||
foreach (long ItemId in ContactIds)
|
||||
if (!await b.DeleteAsync(ItemId, transaction))
|
||||
{
|
||||
AddError(ApiErrorCode.CHILD_OBJECT_ERROR, null, $"HeadOfficeContact [{ItemId}]: {b.GetErrorsAsString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ct.HeadOffice.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -503,7 +494,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//## CREATED / MODIFIED EVENTS
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
{
|
||||
|
||||
//# CONTRACT EXPIRY
|
||||
{
|
||||
|
||||
@@ -152,35 +152,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
LoanUnit dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
LoanUnit dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.LoanUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.LoanUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -303,7 +296,7 @@ namespace AyaNova.Biz
|
||||
private async Task PopulateVizFields(LoanUnit o)
|
||||
{
|
||||
if (o.UnitId != null)
|
||||
o.UnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
o.UnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace AyaNova.Biz
|
||||
internal async Task<Memo> CreateAsync(Memo newObject)
|
||||
{
|
||||
|
||||
newObject.Viewed=false;//default, it's new and not viewed yet but could have been set from a prior forward / reply as it's source
|
||||
newObject.Replied=false;//''
|
||||
newObject.Viewed = false;//default, it's new and not viewed yet but could have been set from a prior forward / reply as it's source
|
||||
newObject.Replied = false;//''
|
||||
await ValidateAsync(newObject);//a bit different, can't update a memo so only need to worry about new objects
|
||||
if (HasErrors)
|
||||
return null;
|
||||
@@ -138,35 +138,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Memo.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Memo.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,37 +136,30 @@ namespace AyaNova.Biz
|
||||
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
//ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.NotifySubscription.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.EventType.ToString(), ct);
|
||||
// await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
|
||||
//TODO: DELETE RELATED RECORDS HERE
|
||||
|
||||
//all good do the commit
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
//ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.NotifySubscription.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.EventType.ToString(), ct);
|
||||
// await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
|
||||
//TODO: DELETE RELATED RECORDS HERE
|
||||
|
||||
//all good do the commit
|
||||
await transaction.CommitAsync();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -231,8 +224,9 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
if(proposedObj.DeliveryMethod==NotifyDeliveryMethod.App && !string.IsNullOrEmpty(proposedObj.DeliveryAddress)){
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "DeliveryAddress","In app delivery should not specify a delivery address");
|
||||
if (proposedObj.DeliveryMethod == NotifyDeliveryMethod.App && !string.IsNullOrEmpty(proposedObj.DeliveryAddress))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "DeliveryAddress", "In app delivery should not specify a delivery address");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -334,43 +334,34 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
PM dbObject = await ct.PM.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// PMGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
PM dbObject = await ct.PM.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// PMGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await PMValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await PMValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.PMItem.AsNoTracking().Where(z => z.PMId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.PMItem.AsNoTracking().Where(z => z.PMId == id).Select(z => z.Id).ToListAsync();
|
||||
ct.PM.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await PMHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
ct.PM.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await PMHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way
|
||||
|
||||
throw;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1196,78 +1187,72 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ItemDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
|
||||
var dbObject = await ct.PMItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await ct.PMItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.PMItemExpense.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.PMItemLabor.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.PMItemLoan.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.PMItemPart.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
var ScheduledUserIds = await ct.PMItemScheduledUser.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.PMItemTask.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.PMItemTravel.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.PMItemUnit.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.PMItemOutsideService.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.PMItemExpense.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.PMItemLabor.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.PMItemLoan.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.PMItemPart.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
ct.PMItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
var ScheduledUserIds = await ct.PMItemScheduledUser.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.PMItemTask.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.PMItemTravel.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.PMItemUnit.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.PMItemOutsideService.Where(z => z.PMItemId == id).Select(z => z.Id).ToListAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.PMId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
ct.PMItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.PMId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1520,28 +1505,22 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ExpenseDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1870,28 +1849,22 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LaborDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2251,29 +2224,22 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LoanDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2648,28 +2614,22 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> OutsideServiceDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2981,32 +2941,24 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> PartDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.PMItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
if (HasErrors)
|
||||
{
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.PMItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
if (HasErrors)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3399,27 +3351,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ScheduledUserDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await ScheduledUserGetAsync(id, false);
|
||||
ScheduledUserValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemScheduledUser.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await ScheduledUserGetAsync(id, false);
|
||||
ScheduledUserValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemScheduledUser.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3638,28 +3582,20 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> TaskDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await TaskGetAsync(id, false);
|
||||
TaskValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemTask.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await TaskGetAsync(id, false);
|
||||
TaskValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemTask.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3914,29 +3850,23 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> TravelDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await TravelGetAsync(id, false);
|
||||
TravelValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemTravel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await TravelGetAsync(id, false);
|
||||
TravelValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemTravel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4283,27 +4213,20 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> UnitDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await UnitGetAsync(id, false);
|
||||
UnitValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await UnitGetAsync(id, false);
|
||||
UnitValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PMItemUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5270,7 +5193,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
thrxxow;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -175,35 +175,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
PartAssembly dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
PartAssembly dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PartAssembly.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PartAssembly.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,35 +152,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Part dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Part dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Part.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Part.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,59 +42,6 @@ namespace AyaNova.Biz
|
||||
internal async Task<PartInventory> CreateAsync(dtPartInventory newDtObject)
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
//get the last record if exists (will not if opening balance)
|
||||
var LastEntry = await ct.PartInventory.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == newDtObject.PartId && m.PartWarehouseId == newDtObject.PartWarehouseId);
|
||||
PartInventory newObject = new PartInventory();
|
||||
newObject.Description = newDtObject.Description;
|
||||
newObject.EntryDate = DateTime.UtcNow;
|
||||
newObject.PartId = newDtObject.PartId;
|
||||
newObject.PartWarehouseId = newDtObject.PartWarehouseId;
|
||||
newObject.SourceId = null;
|
||||
newObject.SourceType = null;
|
||||
newObject.Quantity = newDtObject.Quantity;
|
||||
|
||||
if (LastEntry != null)
|
||||
{
|
||||
newObject.LastEntryDate = LastEntry.EntryDate;
|
||||
newObject.LastBalance = LastEntry.Balance;
|
||||
newObject.Balance = LastEntry.Balance + newObject.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
newObject.Balance = newObject.Quantity;
|
||||
}
|
||||
|
||||
await ValidateAsync(newObject);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
await ct.PartInventory.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
return newObject;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE (internal version)
|
||||
//
|
||||
internal async Task<PartInventory> CreateAsync(dtInternalPartInventory newDtObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
//get the last record if exists (will not if opening balance)
|
||||
var LastEntry = await ct.PartInventory.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == newDtObject.PartId && m.PartWarehouseId == newDtObject.PartWarehouseId);
|
||||
@@ -103,8 +50,8 @@ namespace AyaNova.Biz
|
||||
newObject.EntryDate = DateTime.UtcNow;
|
||||
newObject.PartId = newDtObject.PartId;
|
||||
newObject.PartWarehouseId = newDtObject.PartWarehouseId;
|
||||
newObject.SourceId = newDtObject.SourceId;
|
||||
newObject.SourceType = newDtObject.SourceType;
|
||||
newObject.SourceId = null;
|
||||
newObject.SourceType = null;
|
||||
newObject.Quantity = newDtObject.Quantity;
|
||||
|
||||
if (LastEntry != null)
|
||||
@@ -125,17 +72,53 @@ namespace AyaNova.Biz
|
||||
{
|
||||
await ct.PartInventory.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
return newObject;
|
||||
}
|
||||
}
|
||||
catch
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE (internal version)
|
||||
//
|
||||
internal async Task<PartInventory> CreateAsync(dtInternalPartInventory newDtObject)
|
||||
{
|
||||
//get the last record if exists (will not if opening balance)
|
||||
var LastEntry = await ct.PartInventory.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == newDtObject.PartId && m.PartWarehouseId == newDtObject.PartWarehouseId);
|
||||
PartInventory newObject = new PartInventory();
|
||||
newObject.Description = newDtObject.Description;
|
||||
newObject.EntryDate = DateTime.UtcNow;
|
||||
newObject.PartId = newDtObject.PartId;
|
||||
newObject.PartWarehouseId = newDtObject.PartWarehouseId;
|
||||
newObject.SourceId = newDtObject.SourceId;
|
||||
newObject.SourceType = newDtObject.SourceType;
|
||||
newObject.Quantity = newDtObject.Quantity;
|
||||
|
||||
if (LastEntry != null)
|
||||
{
|
||||
|
||||
throw;
|
||||
newObject.LastEntryDate = LastEntry.EntryDate;
|
||||
newObject.LastBalance = LastEntry.Balance;
|
||||
newObject.Balance = LastEntry.Balance + newObject.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
newObject.Balance = newObject.Quantity;
|
||||
}
|
||||
|
||||
await ValidateAsync(newObject);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
await ct.PartInventory.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
return newObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -152,33 +152,25 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PartWarehouse.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PartWarehouse.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,33 +152,26 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Project.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Project.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
var ret = await ct.PurchaseOrder.Include(z => z.Items).AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (populateDisplayFields)
|
||||
await SetDisplayFields(ret,false);
|
||||
await SetDisplayFields(ret, false);
|
||||
|
||||
if (logTheGetEvent && ret != null)
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||
@@ -323,37 +323,30 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PurchaseOrder.Remove(dbObject);
|
||||
await BizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
if (HasErrors)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PurchaseOrder.Remove(dbObject);
|
||||
await BizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
if (HasErrors)
|
||||
{
|
||||
|
||||
throw;
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,47 +342,38 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Quote dbObject = await ct.Quote.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// QuoteGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Quote dbObject = await ct.Quote.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// QuoteGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await QuoteValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//States collection
|
||||
if (!await StateDeleteAsync(id, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.QuoteItem.AsNoTracking().Where(z => z.QuoteId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
ct.Quote.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await QuoteHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way
|
||||
|
||||
throw;
|
||||
await QuoteValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//States collection
|
||||
if (!await StateDeleteAsync(id, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.QuoteItem.AsNoTracking().Where(z => z.QuoteId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
ct.Quote.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await QuoteHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1027,24 +1018,15 @@ namespace AyaNova.Biz
|
||||
// (note: this would only ever be called when a quote is deleted, there is no direct delete)
|
||||
internal async Task<bool> StateDeleteAsync(long workOrderId, IDbContextTransaction parentTransaction)
|
||||
{
|
||||
try
|
||||
var stateList = await ct.QuoteState.AsNoTracking().Where(z => z.QuoteId == workOrderId).ToListAsync();
|
||||
foreach (var wostate in stateList)
|
||||
{
|
||||
var stateList = await ct.QuoteState.AsNoTracking().Where(z => z.QuoteId == workOrderId).ToListAsync();
|
||||
|
||||
foreach (var wostate in stateList)
|
||||
{
|
||||
ct.QuoteState.Remove(wostate);
|
||||
await ct.SaveChangesAsync();
|
||||
//no need to call this because it's only going to run this method if the quote is deleted and
|
||||
//via process standard notifciation events for quote deletion will remove any state delayed notifications anyway so
|
||||
//nothing to call or do here related to notification
|
||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Deleted, wostate);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
ct.QuoteState.Remove(wostate);
|
||||
await ct.SaveChangesAsync();
|
||||
//no need to call this because it's only going to run this method if the quote is deleted and
|
||||
//via process standard notifciation events for quote deletion will remove any state delayed notifications anyway so
|
||||
//nothing to call or do here related to notification
|
||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Deleted, wostate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1409,78 +1391,71 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ItemDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
var dbObject = await ct.QuoteItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await ct.QuoteItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.QuoteItemExpense.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.QuoteItemLabor.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.QuoteItemLoan.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.QuoteItemPart.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
var ScheduledUserIds = await ct.QuoteItemScheduledUser.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.QuoteItemTask.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.QuoteItemTravel.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.QuoteItemUnit.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.QuoteItemOutsideService.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.QuoteItemExpense.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.QuoteItemLabor.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.QuoteItemLoan.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.QuoteItemPart.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
ct.QuoteItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
var ScheduledUserIds = await ct.QuoteItemScheduledUser.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.QuoteItemTask.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.QuoteItemTravel.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.QuoteItemUnit.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.QuoteItemOutsideService.Where(z => z.QuoteItemId == id).Select(z => z.Id).ToListAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.QuoteId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
ct.QuoteItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.QuoteId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1742,29 +1717,23 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ExpenseDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2112,29 +2081,23 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LaborDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2508,29 +2471,22 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LoanDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2914,28 +2870,20 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> OutsideServiceDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3254,33 +3202,24 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> PartDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.QuoteItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
if (HasErrors)
|
||||
{
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.QuoteItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
if (HasErrors)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3690,27 +3629,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ScheduledUserDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await ScheduledUserGetAsync(id, false);
|
||||
ScheduledUserValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemScheduledUser.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await ScheduledUserGetAsync(id, false);
|
||||
ScheduledUserValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemScheduledUser.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3943,27 +3874,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> TaskDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await TaskGetAsync(id, false);
|
||||
TaskValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemTask.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await TaskGetAsync(id, false);
|
||||
TaskValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemTask.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4227,28 +4150,20 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> TravelDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await TravelGetAsync(id, false);
|
||||
TravelValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemTravel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await TravelGetAsync(id, false);
|
||||
TravelValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemTravel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4614,27 +4529,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> UnitDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await UnitGetAsync(id, false);
|
||||
UnitValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await UnitGetAsync(id, false);
|
||||
UnitValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteItemUnit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET
|
||||
//
|
||||
@@ -107,31 +107,23 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.QuoteStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,35 +152,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Reminder dbObject = await ct.Reminder.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Reminder dbObject = await ct.Reminder.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Reminder.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Reminder.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,29 +208,21 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Report.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Report.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -714,11 +706,7 @@ namespace AyaNova.Biz
|
||||
log.LogInformation(PageLog.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// var v=await page.GetContentAsync();
|
||||
// var v=await page.GetContentAsync();//for debugging purposes
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -152,35 +152,27 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Review.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Review.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,35 +152,27 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.ServiceRate.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.ServiceRate.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,35 +159,26 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
TaskGroup dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
TaskGroup dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TaskGroup.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TaskGroup.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,35 +152,27 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TaxCode.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TaxCode.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,35 +152,27 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TravelRate.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TravelRate.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +245,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!isNew && (proposedObj.Cost != currentObj.Cost || proposedObj.Charge != currentObj.Charge))
|
||||
{
|
||||
|
||||
|
||||
@@ -152,33 +152,25 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Unit dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Unit dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Unit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Unit.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace AyaNova.Biz
|
||||
else
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
await SearchIndexAsync(putObject, false);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||
@@ -153,33 +153,25 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.UnitModel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.UnitModel.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,64 +676,54 @@ namespace AyaNova.Biz
|
||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
||||
if (parentTransaction == null)
|
||||
transaction = await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
User dbObject = await ct.User.SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
User dbObject = await ct.User.SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Also used for Contacts (customer type user or ho type user)
|
||||
//by users with no User right but with Customer rights so need to double check here
|
||||
if (
|
||||
(dbObject.IsOutsideUser && !Authorized.HasDeleteRole(CurrentUserRoles, AyaType.Customer)) ||
|
||||
(!dbObject.IsOutsideUser && !Authorized.HasDeleteRole(CurrentUserRoles, AyaType.User))
|
||||
)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//Delete sibling objects
|
||||
//USEROPTIONS
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from auseroptions where userid = {dbObject.Id}");
|
||||
//NOTIFY SUBSCRIPTIONS
|
||||
//Note: will cascade delete notifyevent, and notification automatically
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotifysubscription where userid = {dbObject.Id}");
|
||||
//personal datalist options
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adatalistsavedfilter where public = {false} and userid = {dbObject.Id}");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adatalistcolumnview where userid = {dbObject.Id}");
|
||||
//Dashboard view
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adashboardview where userid = {dbObject.Id}");
|
||||
|
||||
//Remove the object
|
||||
ct.User.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
|
||||
|
||||
//Also used for Contacts (customer type user or ho type user)
|
||||
//by users with no User right but with Customer rights so need to double check here
|
||||
if (
|
||||
(dbObject.IsOutsideUser && !Authorized.HasDeleteRole(CurrentUserRoles, AyaType.Customer)) ||
|
||||
(!dbObject.IsOutsideUser && !Authorized.HasDeleteRole(CurrentUserRoles, AyaType.User))
|
||||
)
|
||||
{
|
||||
|
||||
//no need to rollback, the transaction will rollback automatically if it's disposed without committing
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
//Note: Transaction does not need to be disposed it will automatically when it goes out of scope due to Using statement
|
||||
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//Delete sibling objects
|
||||
//USEROPTIONS
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from auseroptions where userid = {dbObject.Id}");
|
||||
//NOTIFY SUBSCRIPTIONS
|
||||
//Note: will cascade delete notifyevent, and notification automatically
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotifysubscription where userid = {dbObject.Id}");
|
||||
//personal datalist options
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adatalistsavedfilter where public = {false} and userid = {dbObject.Id}");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adatalistcolumnview where userid = {dbObject.Id}");
|
||||
//Dashboard view
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from adashboardview where userid = {dbObject.Id}");
|
||||
|
||||
//Remove the object
|
||||
ct.User.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -152,31 +152,23 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
Vendor dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
Vendor dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Vendor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Vendor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,36 +195,28 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Widget.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Widget.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
//all good do the commit
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
//all good do the commit
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,47 +361,37 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
WorkOrder dbObject = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// WorkOrderGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
WorkOrder dbObject = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();// WorkOrderGetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
WorkOrderValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//States collection
|
||||
if (!await StateDeleteAsync(id, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.WorkOrderItem.AsNoTracking().Where(z => z.WorkOrderId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
ct.WorkOrder.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way
|
||||
WorkOrderValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
throw;
|
||||
//States collection
|
||||
if (!await StateDeleteAsync(id, transaction))
|
||||
return false;
|
||||
|
||||
}
|
||||
//collect the child id's to delete
|
||||
var ItemIds = await ct.WorkOrderItem.AsNoTracking().Where(z => z.WorkOrderId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ItemIds)
|
||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
ct.WorkOrder.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1405,24 +1395,16 @@ namespace AyaNova.Biz
|
||||
// (note: this would only ever be called when a workorder is deleted, there is no direct delete)
|
||||
internal async Task<bool> StateDeleteAsync(long workOrderId, IDbContextTransaction parentTransaction)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stateList = await ct.WorkOrderState.AsNoTracking().Where(z => z.WorkOrderId == workOrderId).ToListAsync();
|
||||
var stateList = await ct.WorkOrderState.AsNoTracking().Where(z => z.WorkOrderId == workOrderId).ToListAsync();
|
||||
|
||||
foreach (var wostate in stateList)
|
||||
{
|
||||
ct.WorkOrderState.Remove(wostate);
|
||||
await ct.SaveChangesAsync();
|
||||
//no need to call this because it's only going to run this method if the workorder is deleted and
|
||||
//via process standard notifciation events for workorder deletion will remove any state delayed notifications anyway so
|
||||
//nothing to call or do here related to notification
|
||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Deleted, wostate);
|
||||
}
|
||||
}
|
||||
catch
|
||||
foreach (var wostate in stateList)
|
||||
{
|
||||
|
||||
throw;
|
||||
ct.WorkOrderState.Remove(wostate);
|
||||
await ct.SaveChangesAsync();
|
||||
//no need to call this because it's only going to run this method if the workorder is deleted and
|
||||
//via process standard notifciation events for workorder deletion will remove any state delayed notifications anyway so
|
||||
//nothing to call or do here related to notification
|
||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Deleted, wostate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1827,81 +1809,73 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ItemDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
var dbObject = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.WorkOrderItemExpense.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.WorkOrderItemLabor.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.WorkOrderItemLoan.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.WorkOrderItemPart.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartRequestIds = await ct.WorkOrderItemPartRequest.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var ScheduledUserIds = await ct.WorkOrderItemScheduledUser.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.WorkOrderItemTask.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.WorkOrderItemTravel.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.WorkOrderItemUnit.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.WorkOrderItemOutsideService.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
}
|
||||
ItemValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartRequestIds)
|
||||
if (!await PartRequestDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
//collect the child id's to delete
|
||||
var ExpenseIds = await ct.WorkOrderItemExpense.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LaborIds = await ct.WorkOrderItemLabor.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var LoanIds = await ct.WorkOrderItemLoan.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartIds = await ct.WorkOrderItemPart.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var PartRequestIds = await ct.WorkOrderItemPartRequest.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var ScheduledUserIds = await ct.WorkOrderItemScheduledUser.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TaskIds = await ct.WorkOrderItemTask.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var TravelIds = await ct.WorkOrderItemTravel.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var UnitIds = await ct.WorkOrderItemUnit.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
var OutsideServiceIds = await ct.WorkOrderItemOutsideService.Where(z => z.WorkOrderItemId == id).Select(z => z.Id).ToListAsync();
|
||||
ct.WorkOrderItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Delete children
|
||||
foreach (long ItemId in ExpenseIds)
|
||||
if (!await ExpenseDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LaborIds)
|
||||
if (!await LaborDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in LoanIds)
|
||||
if (!await LoanDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartIds)
|
||||
if (!await PartDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in PartRequestIds)
|
||||
if (!await PartRequestDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in ScheduledUserIds)
|
||||
if (!await ScheduledUserDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TaskIds)
|
||||
if (!await TaskDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in TravelIds)
|
||||
if (!await TravelDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in UnitIds)
|
||||
if (!await UnitDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
foreach (long ItemId in OutsideServiceIds)
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.WorkOrderId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
ct.WorkOrderItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "wo:" + dbObject.WorkOrderId.ToString(), ct);//FIX wo?? Not sure what is best here; revisit
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(dbObject.AyaType, dbObject.Id, ct);
|
||||
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//all good do the commit if it's ours
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ItemHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2162,26 +2136,18 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ExpenseDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
var dbObject = await ExpenseGetAsync(id, false);
|
||||
ExpenseValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemExpense.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2518,27 +2484,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LaborDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await LaborGetAsync(id, false);
|
||||
LaborValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemLabor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2899,26 +2857,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> LoanDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await LoanGetAsync(id, false);
|
||||
LoanValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemLoan.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3295,26 +3246,19 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> OutsideServiceDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||
OutsideServiceValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemOutsideService.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3781,34 +3725,26 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> PartDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.WorkOrderItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await PartInventoryAdjustmentAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
if (HasErrors)
|
||||
{
|
||||
var dbObject = await PartGetAsync(id, false);
|
||||
PartValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await PartBizActionsAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
ct.WorkOrderItemPart.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await PartInventoryAdjustmentAsync(AyaEvent.Deleted, null, dbObject, transaction);
|
||||
if (HasErrors)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
await transaction.RollbackAsync();
|
||||
return false;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4352,25 +4288,18 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> PartRequestDeleteAsync(long id, IDbContextTransaction parentTransaction = null)
|
||||
{
|
||||
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var dbObject = await PartRequestGetAsync(id, false);
|
||||
PartRequestValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemPartRequest.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
var dbObject = await PartRequestGetAsync(id, false);
|
||||
PartRequestValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemPartRequest.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix??
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
|
||||
if (parentTransaction == null)
|
||||
await transaction.CommitAsync();
|
||||
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,31 +137,23 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemPriority.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemPriority.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,31 +137,23 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderItemStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,31 +137,23 @@ namespace AyaNova.Biz
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.WorkOrderStatus.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user