diff --git a/server/AyaNova/biz/CustomerServiceRequestBiz.cs b/server/AyaNova/biz/CustomerServiceRequestBiz.cs index bb311650..841ea02e 100644 --- a/server/AyaNova/biz/CustomerServiceRequestBiz.cs +++ b/server/AyaNova/biz/CustomerServiceRequestBiz.cs @@ -240,11 +240,22 @@ namespace AyaNova.Biz //Name required BUT NOT REQUIRED TO BE UNIQUE if (string.IsNullOrWhiteSpace(proposedObj.Name)) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); + AddError(ApiErrorCode.VALIDATION_REQUIRED, "name"); + //test error on name + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "name", "test errror"); + //if unit, it must both exist and belong to this CustomerId + if (proposedObj.UnitId != null) + { + if (!await ct.Unit.AnyAsync(z => z.Id == proposedObj.UnitId && z.CustomerId == proposedObj.CustomerId)) + { + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "unitId", "Unit is not valid, it must exist and belong to the Customer");//no need to localize, this is for api users only as the UI should never allow this + } + } + //Any form customizations to validate?