This commit is contained in:
@@ -448,12 +448,14 @@ namespace AyaNova.Biz
|
|||||||
//Set linked objects
|
//Set linked objects
|
||||||
if (o.BillHeadOffice)
|
if (o.BillHeadOffice)
|
||||||
{
|
{
|
||||||
if (j["HeadOfficeVizNOTPRESETN"] == null)
|
if (j["HeadOfficeViz"] == null)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "HeadOfficeViz");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "HeadOfficeViz");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//if it's not found, it will be zero which will fail validation with a clean error
|
//if it's not found, it will be zero which will fail validation with a clean error
|
||||||
o.HeadOfficeId = await ct.HeadOffice.AsNoTracking().Where(z => z.Name == (string)j["HeadOfficeViz"]).Select(x => x.Id).FirstOrDefaultAsync();
|
o.HeadOfficeId = await ct.HeadOffice.AsNoTracking().Where(z => z.Name == (string)j["HeadOfficeViz"]).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
if (o.HeadOfficeId == 0)
|
||||||
|
AddError(ApiErrorCode.NOT_FOUND, "HeadOfficeViz", $"'{(string)j["HeadOfficeViz"]}'");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user