Removed superfluous try catch throw pattern

This commit is contained in:
2021-08-05 23:14:12 +00:00
parent 7c033a6e84
commit 49bd0d2d87
35 changed files with 2184 additions and 2684 deletions

View File

@@ -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");
}