diff --git a/server/AyaNova/biz/NotifySubscriptionBiz.cs b/server/AyaNova/biz/NotifySubscriptionBiz.cs index f3d7d3a8..54cdd1e3 100644 --- a/server/AyaNova/biz/NotifySubscriptionBiz.cs +++ b/server/AyaNova/biz/NotifySubscriptionBiz.cs @@ -42,7 +42,7 @@ namespace AyaNova.Biz // internal async Task CreateAsync(NotifySubscription newObject) { - await ValidateAsync(newObject); + // await ValidateAsync(newObject); if (HasErrors) return null; else @@ -112,7 +112,7 @@ namespace AyaNova.Biz dbObject.Tags = TagBiz.NormalizeTags(dbObject.Tags); ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency; - await ValidateAsync(dbObject); + // await ValidateAsync(dbObject); if (HasErrors) return null; try { @@ -142,7 +142,7 @@ namespace AyaNova.Biz try { NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == id); - ValidateCanDelete(dbObject); + //ValidateCanDelete(dbObject); if (HasErrors) return false; if (HasErrors) @@ -171,82 +171,82 @@ namespace AyaNova.Biz - //////////////////////////////////////////////////////////////////////////////////////////////// - //VALIDATION - // - private async Task ValidateAsync(NotifySubscription proposedObj) - { + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //VALIDATION + // // + // private async Task ValidateAsync(NotifySubscription proposedObj) + // { - //############################################################################### - //todo: validate subscription is valid - //perhaps check if customer type user doesn't have non customer notification etc + // //############################################################################### + // //todo: validate subscription is valid + // //perhaps check if customer type user doesn't have non customer notification etc - //todo: notifysubscriptionbiz Check for duplicate before accepting new / edit in validator - //DISALLOW entirely duplicate notifications (down to email address) - //USE NAME DUPE CHECK PATTERN BELOW - //############################################################################### + // //todo: notifysubscriptionbiz Check for duplicate before accepting new / edit in validator + // //DISALLOW entirely duplicate notifications (down to email address) + // //USE NAME DUPE CHECK PATTERN BELOW + // //############################################################################### - //NOTE: In DB schema only name and serial are not nullable + // //NOTE: In DB schema only name and serial are not nullable - //run validation and biz rules + // //run validation and biz rules - // //Name required - // if (string.IsNullOrWhiteSpace(proposedObj.Name)) - // AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); + // // //Name required + // // if (string.IsNullOrWhiteSpace(proposedObj.Name)) + // // AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); - // //Name must be less than 255 characters - // if (proposedObj.Name.Length > 255) - // AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "Name", "255 max"); + // // //Name must be less than 255 characters + // // if (proposedObj.Name.Length > 255) + // // AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "Name", "255 max"); - // //If name is otherwise OK, check that name is unique - // if (!PropertyHasErrors("Name")) - // { - // //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false - // if (await ct.NotifySubscription.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id)) - // { - // AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); - // } - // } + // // //If name is otherwise OK, check that name is unique + // // if (!PropertyHasErrors("Name")) + // // { + // // //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false + // // if (await ct.NotifySubscription.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id)) + // // { + // // AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); + // // } + // // } - // //Start date AND end date must both be null or both contain values - // if (proposedObj.StartDate == null && proposedObj.EndDate != null) - // AddError(ApiErrorCode.VALIDATION_REQUIRED, "StartDate"); + // // //Start date AND end date must both be null or both contain values + // // if (proposedObj.StartDate == null && proposedObj.EndDate != null) + // // AddError(ApiErrorCode.VALIDATION_REQUIRED, "StartDate"); - // if (proposedObj.StartDate != null && proposedObj.EndDate == null) - // AddError(ApiErrorCode.VALIDATION_REQUIRED, "EndDate"); + // // if (proposedObj.StartDate != null && proposedObj.EndDate == null) + // // AddError(ApiErrorCode.VALIDATION_REQUIRED, "EndDate"); - // //Start date before end date - // if (proposedObj.StartDate != null && proposedObj.EndDate != null) - // if (proposedObj.StartDate > proposedObj.EndDate) - // AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate"); + // // //Start date before end date + // // if (proposedObj.StartDate != null && proposedObj.EndDate != null) + // // if (proposedObj.StartDate > proposedObj.EndDate) + // // AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate"); - // //Enum is valid value - // if (!proposedObj.UserType.IsValid()) - // { - // AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UserType"); - // } + // // //Enum is valid value + // // if (!proposedObj.UserType.IsValid()) + // // { + // // AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UserType"); + // // } - // //Any form customizations to validate? - // var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.NotifySubscription.ToString()); - // if (FormCustomization != null) - // { - // //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required + // // //Any form customizations to validate? + // // var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.NotifySubscription.ToString()); + // // if (FormCustomization != null) + // // { + // // //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required - // //validate users choices for required non custom fields - // RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj); + // // //validate users choices for required non custom fields + // // RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj); - // //validate custom fields - // CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields); - // } - } + // // //validate custom fields + // // CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields); + // // } + // } - private void ValidateCanDelete(NotifySubscription inObj) - { - //whatever needs to be check to delete this object - } + // private void ValidateCanDelete(NotifySubscription inObj) + // { + // //whatever needs to be check to delete this object + // }