This commit is contained in:
2023-01-08 19:52:13 +00:00
parent 5cc450eef8
commit adc85f43cc
2 changed files with 103 additions and 4 deletions

View File

@@ -562,6 +562,105 @@ namespace Sockeye.Biz
{
bool isNew = currentObj == null;
//fetched keys are never editable, must be duped if re-issue
if (currentObj.FetchedOn != null)
{
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", "Fetched, not changeable, duplicate instead");
return;
}
//MISC product group is not valid for keys
if (currentObj.PGroup == ProductGroup.Misc)
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "pGroup");
return;
}
//If Active and fetchable (and were here as it's not yet fetched)
//then more rules apply than if just saving while working on it...
if (proposedObj.Active)
{
//It's being offered for fetch so make sure it's ready here
if (string.IsNullOrWhiteSpace(proposedObj.RegTo))
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "RegTo");
return;
}
if (proposedObj.Users < 1)//both require Users to be set
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Users");
return;
}
//all non trial keys require a customer id matched
if (proposedObj.CustomerId == null && !proposedObj.TrialMode)
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "CustomerId");
return;
}
//Active state rules for each product group
switch (proposedObj.PGroup)
{
case ProductGroup.RavenPerpetual:
{
if (string.IsNullOrWhiteSpace(proposedObj.DbId))
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "DbID");
return;
}
}
break;
case ProductGroup.RavenSubscription:
{
if (string.IsNullOrWhiteSpace(proposedObj.DbId))
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "DbID");
return;
}
//sub keys *always* expire
if (proposedObj.LicenseExpire == null)
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "LicenseExpire");
return;
}
if (proposedObj.CustomerUsers < 250)
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "CustomerUsers");
return;
}
if (proposedObj.MaxDataGB == null || proposedObj.MaxDataGB < 20)
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "MaxDataGB");
return;
}
}
break;
case ProductGroup.AyaNova7:
{
if (string.IsNullOrWhiteSpace(proposedObj.FetchEmail))
{
AddError(ApiErrorCode.VALIDATION_REQUIRED, "FetchEmail");
return;
}
}
break;
}
}
//Any form customizations to validate?
@@ -581,9 +680,9 @@ namespace Sockeye.Biz
private void ValidateCanDeleteAsync(License inObj)
{
if(inObj.FetchedOn!=null)
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", "Fetched, not deletable");
if (inObj.FetchedOn != null)
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", "Fetched, not deletable");
}