This commit is contained in:
2021-01-23 15:56:34 +00:00
parent 93efa6fb5a
commit c07a116cf3
8 changed files with 21 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace AyaNova.Biz namespace AyaNova.Biz
{ {
@@ -30,7 +31,10 @@ namespace AyaNova.Biz
#endregion #endregion
internal async Task<string> Translate(string key)
{
return await TranslationBiz.GetTranslationStaticAsync(key, UserTranslationId, ct);
}
#region Error handling #region Error handling
private readonly List<ValidationError> _errors = new List<ValidationError>(); private readonly List<ValidationError> _errors = new List<ValidationError>();

View File

@@ -299,7 +299,7 @@ namespace AyaNova.Biz
{ {
//Note: errorbox will ensure it appears in the general errror box and not field specific //Note: errorbox will ensure it appears in the general errror box and not field specific
//the translation key is to indicate what the linked object is that is causing the error //the translation key is to indicate what the linked object is that is causing the error
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", "LT:Customer"); AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Customer"));
} }
} }

View File

@@ -267,7 +267,7 @@ namespace AyaNova.Biz
//PartInventory record? //PartInventory record?
if (await ct.PartInventory.AnyAsync(m => m.PartWarehouseId == inObj.Id)) if (await ct.PartInventory.AnyAsync(m => m.PartWarehouseId == inObj.Id))
{ {
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await TranslationBiz.GetTranslationStaticAsync("PartInventoryTransaction", UserTranslationId, ct)); AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PartInventoryTransaction"));
} }
} }

View File

@@ -91,7 +91,7 @@ namespace AyaNova.Biz
var querySegments = AutoCompleteQuery.Split(' '); var querySegments = AutoCompleteQuery.Split(' ');
if (querySegments.Length > 2) if (querySegments.Length > 2)
{ {
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", await Translate("ErrorPickListQueryInvalid"));
return null; return null;
} }
//check the two query segments, it's valid for the user to put the tag first or the template query first //check the two query segments, it's valid for the user to put the tag first or the template query first
@@ -108,7 +108,7 @@ namespace AyaNova.Biz
} }
else else
{ {
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", await Translate("ErrorPickListQueryInvalid"));
return null; return null;
} }

View File

@@ -321,7 +321,7 @@ namespace AyaNova.Biz
{ {
//Note: errorbox will ensure it appears in the general errror box and not field specific //Note: errorbox will ensure it appears in the general errror box and not field specific
//the translation key is to indicate what the linked object is that is causing the error //the translation key is to indicate what the linked object is that is causing the error
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", "LT:NotifySubscription"); AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("NotifySubscription"));
} }
} }

View File

@@ -205,17 +205,17 @@ namespace AyaNova.Biz
//values must add up //values must add up
if (proposedObj.IncidentsBalance != (proposedObj.Incidents + (proposedObj.LastIncidentsBalance ?? 0))) if (proposedObj.IncidentsBalance != (proposedObj.Incidents + (proposedObj.LastIncidentsBalance ?? 0)))
{ {
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", "LT:ServiceBankIncidentsBalance"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", await Translate("ServiceBankIncidentsBalance"));
return; return;
} }
if (proposedObj.CurrencyBalance != (proposedObj.Currency + (proposedObj.LastCurrencyBalance ?? 0))) if (proposedObj.CurrencyBalance != (proposedObj.Currency + (proposedObj.LastCurrencyBalance ?? 0)))
{ {
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", "LT:ServiceBankCurrencyBalance"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", await Translate("ServiceBankCurrencyBalance"));
return; return;
} }
if (proposedObj.HoursBalance != (proposedObj.Hours + (proposedObj.LastHoursBalance ?? 0))) if (proposedObj.HoursBalance != (proposedObj.Hours + (proposedObj.LastHoursBalance ?? 0)))
{ {
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", "LT:ServiceBankHoursBalance"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "generalerror", await Translate("ServiceBankHoursBalance"));
return; return;
} }

View File

@@ -273,7 +273,7 @@ namespace AyaNova.Biz
//Can't delete a unit if it's a shadow unit for a loanunit //Can't delete a unit if it's a shadow unit for a loanunit
if (await ct.LoanUnit.AnyAsync(z => z.UnitId == inObj.Id)) if (await ct.LoanUnit.AnyAsync(z => z.UnitId == inObj.Id))
{ {
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", "LT:LoanUnit"); AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("LoanUnit"));
} }
} }

View File

@@ -667,7 +667,7 @@ namespace AyaNova.Biz
if (isNew) if (isNew)
{ {
//This operation is about to consume one more license, check that we are not at the limit already //This operation is about to consume one more license, check that we are not at the limit already
CheckActiveForValidation(CurrentActiveCount, LicensedUserCount); await CheckActiveForValidation(CurrentActiveCount, LicensedUserCount);
} }
else else
{ {
@@ -676,7 +676,7 @@ namespace AyaNova.Biz
{ {
//going from non tech to tech and active //going from non tech to tech and active
//Yes, this is about to consume one more license, check that we are not at the limit already //Yes, this is about to consume one more license, check that we are not at the limit already
CheckActiveForValidation(CurrentActiveCount, LicensedUserCount); await CheckActiveForValidation(CurrentActiveCount, LicensedUserCount);
} }
} }
} }
@@ -805,11 +805,11 @@ namespace AyaNova.Biz
return; return;
} }
private void CheckActiveForValidation(long CurrentActiveCount, long LicensedUserCount) private async Task CheckActiveForValidation(long CurrentActiveCount, long LicensedUserCount)
{ {
if (CurrentActiveCount >= LicensedUserCount) if (CurrentActiveCount >= LicensedUserCount)
{ {
AddError(ApiErrorCode.INVALID_OPERATION, null, "LT:ErrorSecurityUserCapacity"); AddError(ApiErrorCode.INVALID_OPERATION, null, await Translate("ErrorSecurityUserCapacity"));
} }
} }
@@ -831,7 +831,8 @@ namespace AyaNova.Biz
//if (await ct.Event.Select(z => z).Where(z => z.UserId == inObj.Id).Count() > 0) //if (await ct.Event.Select(z => z).Where(z => z.UserId == inObj.Id).Count() > 0)
if (await ct.Event.AnyAsync(z => z.UserId == inObj.Id)) if (await ct.Event.AnyAsync(z => z.UserId == inObj.Id))
{ {
AddError(ApiErrorCode.INVALID_OPERATION, null, "LT:ErrorDBForeignKeyViolation"); //todo: Hold up, shouldt this be: AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("NotifySubscription"));
AddError(ApiErrorCode.INVALID_OPERATION, null, await Translate("ErrorDBForeignKeyViolation"));
return; return;
} }