From adc85f43ccdf7c7d3d5517e24807bcfc89c4d1cb Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 8 Jan 2023 19:52:13 +0000 Subject: [PATCH] --- server/biz/LicenseBiz.cs | 105 +++++++++++++++++++++++++++++++++++++-- server/models/License.cs | 2 +- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/server/biz/LicenseBiz.cs b/server/biz/LicenseBiz.cs index 5f47e99..f4d9356 100644 --- a/server/biz/LicenseBiz.cs +++ b/server/biz/LicenseBiz.cs @@ -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"); + } diff --git a/server/models/License.cs b/server/models/License.cs index 9de1836..e8b9572 100644 --- a/server/models/License.cs +++ b/server/models/License.cs @@ -38,7 +38,7 @@ namespace Sockeye.Models [NotMapped] public int? MaxDataGB { get; set; }//v8 - subscription only [NotMapped] - public bool TrialMode { get; set; } = false;//v8 + public bool TrialMode { get; set; } = false;//v8 indicates it was requested by user as trial request or manually created as a trial request in UI //shared dto props [NotMapped] public int Users { get; set; }//v7 scheduled users, v8 internal users