This commit is contained in:
2021-07-13 17:55:36 +00:00
parent 7d5b49c950
commit b1880ecf04
6 changed files with 40 additions and 11 deletions

View File

@@ -12,7 +12,11 @@ namespace AyaNova.Biz
//Returns the biz object class that corresponds to the type presented
//Used by SEARCH, REPORTING and objects with JOBS
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All, long translationId = 0)
internal static BizObject GetBizObject(AyaType ayaType,
AyContext ct,
long userId = 1,
AuthorizationRoles roles = AuthorizationRoles.All,
long translationId = 0)
{
if (translationId == 0)
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
@@ -92,7 +96,7 @@ namespace AyaNova.Biz
case AyaType.WorkOrderItemTravel:
case AyaType.WorkOrderItemUnit:
case AyaType.WorkOrderItemOutsideService:
return new WorkOrderBiz(ct, userId, translationId, roles);
return new WorkOrderBiz(ct, userId, translationId, roles, UserType.NotService);//default to not service for now arbitrarily on the principle of least access
//---
case AyaType.WorkOrderTemplate:
return new WorkOrderTemplateBiz(ct, userId, translationId, roles);

View File

@@ -18,7 +18,7 @@ namespace AyaNova.Biz
{
// //Feature specific roles
internal WorkOrderBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
internal WorkOrderBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles, UserType currentUserType)
{
ct = dbcontext;
UserId = currentUserId;
@@ -30,9 +30,17 @@ namespace AyaNova.Biz
internal static WorkOrderBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
{
if (httpContext != null)
return new WorkOrderBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
return new WorkOrderBiz(ct,
UserIdFromContext.Id(httpContext.Items),
UserTranslationIdFromContext.Id(httpContext.Items),
UserRolesFromContext.Roles(httpContext.Items),
UserTypeFromContext.Type(httpContext.Items));
else
return new WorkOrderBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdmin);
return new WorkOrderBiz(ct,
1,
ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID,
AuthorizationRoles.BizAdmin,
UserType.NotService);//picked not service arbitrarily, probably a non-factor
}
@@ -3736,7 +3744,7 @@ namespace AyaNova.Biz
if (proposedObj.UnitId < 1 || !await ct.Unit.AnyAsync(x => x.Id == proposedObj.UnitId))
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UnitId");
//Any form customizations to validate?
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.WorkOrderItemOutsideService.ToString());
if (FormCustomization != null)
@@ -4465,7 +4473,7 @@ namespace AyaNova.Biz
}
}
if (!await BizObjectExistsInDatabase.ExistsAsync(AyaType.Part, proposedObj.PartId, ct))
if (!await BizObjectExistsInDatabase.ExistsAsync(AyaType.Part, proposedObj.PartId, ct))
{
AddError(ApiErrorCode.NOT_FOUND, "PartId");
return;
@@ -4973,7 +4981,7 @@ namespace AyaNova.Biz
}
}
if (proposedObj.EstimatedQuantity < 0)//negative quantities are not allowed
if (proposedObj.EstimatedQuantity < 0)//negative quantities are not allowed
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "EstimatedQuantity");