From 7f23855bf84924d007336cc051327fe7e3b10f5c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 7 Jan 2021 19:13:13 +0000 Subject: [PATCH] --- server/AyaNova/biz/CustomerServiceRequestBiz.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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?