Stubbing out workorder
This commit is contained in:
@@ -10,6 +10,8 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
internal class WorkOrderBiz : BizObject, ISearchAbleObject
|
internal class WorkOrderBiz : BizObject, ISearchAbleObject
|
||||||
{
|
{
|
||||||
|
//Feature specific roles
|
||||||
|
internal static AuthorizationRoles RolesAllowedToChangeSerial = AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.AccountingFull;
|
||||||
|
|
||||||
internal WorkOrderBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
|
internal WorkOrderBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
|
||||||
{
|
{
|
||||||
@@ -63,6 +65,13 @@ namespace AyaNova.Biz
|
|||||||
internal async Task<WorkOrder> CreateAsync(long? workorderTemplateId, long? customerId, uint? serial)
|
internal async Task<WorkOrder> CreateAsync(long? workorderTemplateId, long? customerId, uint? serial)
|
||||||
{
|
{
|
||||||
//Create and save to db a new workorder and return it
|
//Create and save to db a new workorder and return it
|
||||||
|
//NOTE: Serial can be specified or edited after the fact in a limited way by full role specfic only!! (service manager, bizadminfull, accounting maybe)
|
||||||
|
|
||||||
|
if (serial != null && CurrentUserRoles.HasFlag(RolesAllowedToChangeSerial))
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.NOT_AUTHORIZED, "Serial");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// await ValidateAsync(inObj, null);
|
// await ValidateAsync(inObj, null);
|
||||||
@@ -84,7 +93,7 @@ namespace AyaNova.Biz
|
|||||||
//Handle child and associated items:
|
//Handle child and associated items:
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, o.Id, BizType, AyaEvent.Created), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, o.Id, BizType, AyaEvent.Created), ct);
|
||||||
await SearchIndexAsync(o, true);
|
await SearchIndexAsync(o, true);
|
||||||
// await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, o.Tags, null);
|
// await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, o.Tags, null);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
//}
|
//}
|
||||||
@@ -135,34 +144,40 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
|
|
||||||
//put
|
//put
|
||||||
internal async Task<bool> PutAsync(WorkOrder dbObj, WorkOrder inObj)
|
internal async Task<bool> PutAsync(WorkOrder dbObj, WorkOrder putObj)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException("STUB: WORKORDER PUT");
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
// WorkOrder SnapshotOfOriginalDBObj = new WorkOrder();
|
|
||||||
// CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
// //Replace the db object with the PUT object
|
// make a snapshot of the original for validation but update the original to preserve workflow
|
||||||
// CopyObject.Copy(inObj, dbObj, "Id");
|
WorkOrder SnapshotOfOriginalDBObj = new WorkOrder();
|
||||||
|
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
||||||
|
|
||||||
// dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
//Replace the db object with the PUT object
|
||||||
// dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
CopyObject.Copy(putObj, dbObj, "Id,Serial");
|
||||||
|
|
||||||
// //Set "original" value of concurrency token to input token
|
//if user has rights then change it, otherwise just ignore it and do the rest
|
||||||
// //this will allow EF to check it out
|
if (SnapshotOfOriginalDBObj.Serial != putObj.Serial && CurrentUserRoles.HasFlag(RolesAllowedToChangeSerial))
|
||||||
// ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
|
{
|
||||||
|
dbObj.Serial = putObj.Serial;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
||||||
|
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
||||||
|
|
||||||
|
//Set "original" value of concurrency token to input token
|
||||||
|
//this will allow EF to check it out
|
||||||
|
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = putObj.ConcurrencyToken;
|
||||||
|
|
||||||
|
|
||||||
// await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
||||||
// if (HasErrors)
|
if (HasErrors)
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
// //Log event and save context
|
//Log event and save context
|
||||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
||||||
// await SearchIndexAsync(dbObj, false);
|
await SearchIndexAsync(dbObj, false);
|
||||||
// await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
|
|
||||||
// return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user